- added more info if we get mutex errors in the lobby

This commit is contained in:
Mark Vejvoda 2011-07-02 07:36:28 +00:00
parent 1a5c70c76e
commit 8e1836220d
2 changed files with 8 additions and 4 deletions

View File

@ -72,6 +72,8 @@ private:
SDL_mutex* mutex; SDL_mutex* mutex;
int refCount; int refCount;
string ownerId; string ownerId;
string deleteownerId;
public: public:
Mutex(string ownerId=""); Mutex(string ownerId="");
~Mutex(); ~Mutex();

View File

@ -87,22 +87,24 @@ Mutex::Mutex(string ownerId) {
snprintf(szBuf,1023,"In [%s::%s Line: %d] mutex == NULL",__FILE__,__FUNCTION__,__LINE__); snprintf(szBuf,1023,"In [%s::%s Line: %d] mutex == NULL",__FILE__,__FUNCTION__,__LINE__);
throw runtime_error(szBuf); throw runtime_error(szBuf);
} }
deleteownerId = "";
} }
Mutex::~Mutex() { Mutex::~Mutex() {
if(mutex == NULL) { if(mutex == NULL) {
char szBuf[1024]=""; 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); throw runtime_error(szBuf);
//printf("%s\n",szBuf); //printf("%s\n",szBuf);
} }
else if(refCount >= 1) { else if(refCount >= 1) {
char szBuf[1024]=""; 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); throw runtime_error(szBuf);
} }
if(mutex != NULL) { if(mutex != NULL) {
deleteownerId = ownerId;
SDL_DestroyMutex(mutex); SDL_DestroyMutex(mutex);
mutex=NULL; mutex=NULL;
} }
@ -111,7 +113,7 @@ Mutex::~Mutex() {
void Mutex::p() { void Mutex::p() {
if(mutex == NULL) { if(mutex == NULL) {
char szBuf[1024]=""; 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); throw runtime_error(szBuf);
} }
SDL_mutexP(mutex); SDL_mutexP(mutex);
@ -121,7 +123,7 @@ void Mutex::p() {
void Mutex::v() { void Mutex::v() {
if(mutex == NULL) { if(mutex == NULL) {
char szBuf[1024]=""; 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); throw runtime_error(szBuf);
} }
refCount--; refCount--;