From 8e1836220d699db9ba4e7edb2d9c017a425ef28a Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Sat, 2 Jul 2011 07:36:28 +0000 Subject: [PATCH] - added more info if we get mutex errors in the lobby --- source/shared_lib/include/platform/sdl/thread.h | 2 ++ source/shared_lib/sources/platform/sdl/thread.cpp | 10 ++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/source/shared_lib/include/platform/sdl/thread.h b/source/shared_lib/include/platform/sdl/thread.h index f7fa8a191..1b8a43faa 100644 --- a/source/shared_lib/include/platform/sdl/thread.h +++ b/source/shared_lib/include/platform/sdl/thread.h @@ -72,6 +72,8 @@ private: SDL_mutex* mutex; int refCount; string ownerId; + string deleteownerId; + public: Mutex(string ownerId=""); ~Mutex(); diff --git a/source/shared_lib/sources/platform/sdl/thread.cpp b/source/shared_lib/sources/platform/sdl/thread.cpp index 8dad875c3..991689e56 100644 --- a/source/shared_lib/sources/platform/sdl/thread.cpp +++ b/source/shared_lib/sources/platform/sdl/thread.cpp @@ -87,22 +87,24 @@ Mutex::Mutex(string ownerId) { snprintf(szBuf,1023,"In [%s::%s Line: %d] mutex == NULL",__FILE__,__FUNCTION__,__LINE__); throw runtime_error(szBuf); } + deleteownerId = ""; } Mutex::~Mutex() { if(mutex == NULL) { char szBuf[1024]=""; - snprintf(szBuf,1023,"In [%s::%s Line: %d] mutex == NULL refCount = %d owner [%s]",__FILE__,__FUNCTION__,__LINE__,refCount,ownerId.c_str()); + snprintf(szBuf,1023,"In [%s::%s Line: %d] mutex == NULL refCount = %d owner [%s] deleteownerId [%s]",__FILE__,__FUNCTION__,__LINE__,refCount,ownerId.c_str(),deleteownerId.c_str()); throw runtime_error(szBuf); //printf("%s\n",szBuf); } else if(refCount >= 1) { char szBuf[1024]=""; - snprintf(szBuf,1023,"In [%s::%s Line: %d] about to destroy mutex refCount = %d owner [%s]",__FILE__,__FUNCTION__,__LINE__,refCount,ownerId.c_str()); + snprintf(szBuf,1023,"In [%s::%s Line: %d] about to destroy mutex refCount = %d owner [%s] deleteownerId [%s]",__FILE__,__FUNCTION__,__LINE__,refCount,ownerId.c_str(),deleteownerId.c_str()); throw runtime_error(szBuf); } if(mutex != NULL) { + deleteownerId = ownerId; SDL_DestroyMutex(mutex); mutex=NULL; } @@ -111,7 +113,7 @@ Mutex::~Mutex() { void Mutex::p() { if(mutex == NULL) { char szBuf[1024]=""; - snprintf(szBuf,1023,"In [%s::%s Line: %d] mutex == NULL refCount = %d owner [%s]",__FILE__,__FUNCTION__,__LINE__,refCount,ownerId.c_str()); + snprintf(szBuf,1023,"In [%s::%s Line: %d] mutex == NULL refCount = %d owner [%s] deleteownerId [%s]",__FILE__,__FUNCTION__,__LINE__,refCount,ownerId.c_str(),deleteownerId.c_str()); throw runtime_error(szBuf); } SDL_mutexP(mutex); @@ -121,7 +123,7 @@ void Mutex::p() { void Mutex::v() { if(mutex == NULL) { char szBuf[1024]=""; - snprintf(szBuf,1023,"In [%s::%s Line: %d] mutex == NULL refCount = %d owner [%s]",__FILE__,__FUNCTION__,__LINE__,refCount,ownerId.c_str()); + snprintf(szBuf,1023,"In [%s::%s Line: %d] mutex == NULL refCount = %d owner [%s] deleteownerId [%s]",__FILE__,__FUNCTION__,__LINE__,refCount,ownerId.c_str(),deleteownerId.c_str()); throw runtime_error(szBuf); } refCount--;