diff --git a/source/glest_game/game/commander.cpp b/source/glest_game/game/commander.cpp index ab57d4bbc..c19d46312 100644 --- a/source/glest_game/game/commander.cpp +++ b/source/glest_game/game/commander.cpp @@ -61,7 +61,7 @@ void CommanderNetworkThread::setQuitStatus(bool value) { void CommanderNetworkThread::signalUpdate(int id) { //SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] event = %p\n",__FILE__,__FUNCTION__,__LINE__,event); - MutexSafeWrapper safeMutex(&idMutex); + MutexSafeWrapper safeMutex(&idMutex,string(__FILE__) + "_" + intToStr(__LINE__)); this->idStatus.first = id; this->idStatus.second = false; safeMutex.ReleaseLock(); @@ -73,7 +73,7 @@ void CommanderNetworkThread::signalUpdate(int id) { void CommanderNetworkThread::setTaskCompleted(int id) { //SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__); - MutexSafeWrapper safeMutex(&idMutex); + MutexSafeWrapper safeMutex(&idMutex,string(__FILE__) + "_" + intToStr(__LINE__)); this->idStatus.second = true; safeMutex.ReleaseLock(); @@ -82,7 +82,7 @@ void CommanderNetworkThread::setTaskCompleted(int id) { bool CommanderNetworkThread::isSignalCompleted(int id) { //SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] slotIndex = %d\n",__FILE__,__FUNCTION__,__LINE__,slotIndex); - MutexSafeWrapper safeMutex(&idMutex); + MutexSafeWrapper safeMutex(&idMutex,string(__FILE__) + "_" + intToStr(__LINE__)); bool result = this->idStatus.second; safeMutex.ReleaseLock(); //if(result == false) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] slotIndex = %d, result = %d\n",__FILE__,__FUNCTION__,__LINE__,slotIndex,result); @@ -113,7 +113,7 @@ void CommanderNetworkThread::execute() { //SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); - MutexSafeWrapper safeMutex(&idMutex); + MutexSafeWrapper safeMutex(&idMutex,string(__FILE__) + "_" + intToStr(__LINE__)); if(idStatus.first > 0) { int updateId = this->idStatus.first; safeMutex.ReleaseLock(); diff --git a/source/glest_game/graphics/renderer.cpp b/source/glest_game/graphics/renderer.cpp index 4dd0121f9..547d5c4a8 100644 --- a/source/glest_game/graphics/renderer.cpp +++ b/source/glest_game/graphics/renderer.cpp @@ -237,7 +237,7 @@ void Renderer::simpleTask(BaseThread *callingThread) { // This code reads pixmaps from a queue and saves them to disk Pixmap2D *savePixMapBuffer=NULL; string path=""; - MutexSafeWrapper safeMutex(&saveScreenShotThreadAccessor); + MutexSafeWrapper safeMutex(&saveScreenShotThreadAccessor,string(__FILE__) + "_" + intToStr(__LINE__)); if(saveScreenQueue.size() > 0) { SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d] saveScreenQueue.size() = %d\n",__FILE__,__FUNCTION__,__LINE__,saveScreenQueue.size()); @@ -3537,7 +3537,7 @@ void Renderer::saveScreen(const string &path) { SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); // Signal the threads queue to add a screenshot save request - MutexSafeWrapper safeMutex(&saveScreenShotThreadAccessor); + MutexSafeWrapper safeMutex(&saveScreenShotThreadAccessor,string(__FILE__) + "_" + intToStr(__LINE__)); saveScreenQueue.push_back(make_pair(path,pixmapScreenShot)); safeMutex.ReleaseLock(); @@ -3545,7 +3545,7 @@ void Renderer::saveScreen(const string &path) { } unsigned int Renderer::getSaveScreenQueueSize() { - MutexSafeWrapper safeMutex(&saveScreenShotThreadAccessor); + MutexSafeWrapper safeMutex(&saveScreenShotThreadAccessor,string(__FILE__) + "_" + intToStr(__LINE__)); int queueSize = saveScreenQueue.size(); safeMutex.ReleaseLock(); diff --git a/source/glest_game/menu/menu_state_connected_game.cpp b/source/glest_game/menu/menu_state_connected_game.cpp index 755ca690e..3e9a46147 100644 --- a/source/glest_game/menu/menu_state_connected_game.cpp +++ b/source/glest_game/menu/menu_state_connected_game.cpp @@ -877,7 +877,7 @@ void MenuStateConnectedGame::update() { if(clientInterface->getAllowGameDataSynchCheck() == false) { Config &config = Config::getInstance(); - MutexSafeWrapper safeMutexFTPProgress(ftpClientThread != NULL ? ftpClientThread->getProgressMutex() : NULL); + MutexSafeWrapper safeMutexFTPProgress(ftpClientThread != NULL ? ftpClientThread->getProgressMutex() : NULL,string(__FILE__) + "_" + intToStr(__LINE__)); const GameSettings *gameSettings = clientInterface->getGameSettings(); int32 tilesetCRC = getFolderTreeContentsCheckSumRecursively(config.getPathListForType(ptTilesets,""), string("/") + gameSettings->getTileset() + string("/*"), ".xml", NULL); // Test data synch @@ -1816,7 +1816,7 @@ void MenuStateConnectedGame::FTPClient_CallbackEvent(string itemName, FTP_Client getMissingMapFromFTPServerInProgress = false; if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Got FTP Callback for [%s] result = %d\n",itemName.c_str(),result); - MutexSafeWrapper safeMutexFTPProgress(ftpClientThread->getProgressMutex()); + MutexSafeWrapper safeMutexFTPProgress(ftpClientThread->getProgressMutex(),string(__FILE__) + "_" + intToStr(__LINE__)); fileFTPProgressList.erase(itemName); safeMutexFTPProgress.ReleaseLock(); @@ -1854,7 +1854,7 @@ void MenuStateConnectedGame::FTPClient_CallbackEvent(string itemName, FTP_Client getMissingTilesetFromFTPServerInProgress = false; if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Got FTP Callback for [%s] result = %d\n",itemName.c_str(),result); - MutexSafeWrapper safeMutexFTPProgress(ftpClientThread->getProgressMutex()); + MutexSafeWrapper safeMutexFTPProgress(ftpClientThread->getProgressMutex(),string(__FILE__) + "_" + intToStr(__LINE__)); fileFTPProgressList.erase(itemName); safeMutexFTPProgress.ReleaseLock(true); diff --git a/source/glest_game/menu/menu_state_custom_game.cpp b/source/glest_game/menu/menu_state_custom_game.cpp index a69194f75..5a6ff0682 100644 --- a/source/glest_game/menu/menu_state_custom_game.cpp +++ b/source/glest_game/menu/menu_state_custom_game.cpp @@ -619,7 +619,7 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton){ soundRenderer.playFx(coreData.getClickSoundA()); - MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL)); + MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__)); needToBroadcastServerSettings = false; needToRepublishToMasterserver = false; lastNetworkPing = time(NULL); @@ -652,7 +652,7 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton){ else if(listBoxMap.mouseClick(x, y)){ SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s\n", getCurrentMapFile().c_str()); - MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL)); + MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__)); loadMapInfo(Map::getMapPath(getCurrentMapFile(),"",false), &mapInfo, true); labelMapInfo.setText(mapInfo.desc); @@ -671,7 +671,7 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton){ } } else if (listBoxAdvanced.getSelectedItemIndex() == 1 && listBoxFogOfWar.mouseClick(x, y)) { - MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL)); + MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__)); if(listBoxPublishServer.getSelectedItemIndex() == 0) { needToRepublishToMasterserver = true; @@ -684,7 +684,7 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton){ } } else if (listBoxAdvanced.getSelectedItemIndex() == 1 && listBoxAllowObservers.mouseClick(x, y)) { - MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL)); + MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__)); if(listBoxPublishServer.getSelectedItemIndex() == 0) { needToRepublishToMasterserver = true; @@ -698,7 +698,7 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton){ } } else if (listBoxAdvanced.getSelectedItemIndex() == 1 && listBoxEnableObserverMode.mouseClick(x, y)) { - MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL)); + MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__)); if(listBoxPublishServer.getSelectedItemIndex() == 0) { needToRepublishToMasterserver = true; @@ -711,7 +711,7 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton){ } } else if (listBoxAdvanced.getSelectedItemIndex() == 1 && listBoxPathFinderType.mouseClick(x, y)) { - MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL)); + MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__)); if(listBoxPublishServer.getSelectedItemIndex() == 0) { needToRepublishToMasterserver = true; @@ -727,7 +727,7 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton){ //TODO } else if(listBoxTileset.mouseClick(x, y)){ - MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL)); + MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__)); if(listBoxPublishServer.getSelectedItemIndex() == 0) { needToRepublishToMasterserver = true; @@ -741,7 +741,7 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton){ } } else if(listBoxMapFilter.mouseClick(x, y)){ - MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL)); + MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__)); switchToNextMapGroup(listBoxMapFilter.getSelectedItemIndex()-oldListBoxMapfilterIndex); SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s\n", getCurrentMapFile().c_str()); @@ -763,7 +763,7 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton){ else if(listBoxTechTree.mouseClick(x, y)){ reloadFactions(false); - MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL)); + MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__)); if(listBoxPublishServer.getSelectedItemIndex() == 0) { needToRepublishToMasterserver = true; @@ -776,12 +776,12 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton){ } } else if(listBoxPublishServer.mouseClick(x, y) && listBoxPublishServer.getEditable()) { - MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL)); + MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__)); needToRepublishToMasterserver = true; soundRenderer.playFx(coreData.getClickSoundC()); } else if(listBoxAdvanced.getSelectedItemIndex() == 1 && listBoxNetworkPauseGameForLaggedClients.mouseClick(x, y)){ - MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL)); + MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__)); if(listBoxPublishServer.getSelectedItemIndex() == 0) { needToRepublishToMasterserver = true; @@ -796,7 +796,7 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton){ } else { for(int i=0; igetMutexThreadObjectAccessor() : NULL)); + MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__)); if (listBoxAdvanced.getSelectedItemIndex() == 1) { // set multiplier @@ -982,7 +982,7 @@ void MenuStateCustomGame::RestoreLastGameSettings() { ServerInterface* serverInterface= NetworkManager::getInstance().getServerInterface(); serverInterface->setGameSettings(&gameSettings,false); - MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL)); + MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__)); if(listBoxPublishServer.getSelectedItemIndex() == 0) { needToRepublishToMasterserver = true; @@ -996,7 +996,7 @@ void MenuStateCustomGame::RestoreLastGameSettings() { } void MenuStateCustomGame::PlayNow() { - MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL)); + MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__)); saveGameSettingsToFile("lastCustomGamSettings.mgg"); closeUnusedSlots(); @@ -1379,7 +1379,7 @@ void MenuStateCustomGame::update() { //sleep(200); // END - MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL)); + MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__)); try { if(serverInitError == true) { @@ -1870,14 +1870,14 @@ void MenuStateCustomGame::simpleTask(BaseThread *callingThread) { try { //printf("-=-=-=-=- IN MenuStateCustomGame simpleTask - A\n"); - MutexSafeWrapper safeMutexThreadOwner(callingThread->getMutexThreadOwnerValid()); + MutexSafeWrapper safeMutexThreadOwner(callingThread->getMutexThreadOwnerValid(),string(__FILE__) + "_" + intToStr(__LINE__)); if(callingThread->getQuitStatus() == true || safeMutexThreadOwner.isValidMutex() == false) { return; } //printf("-=-=-=-=- IN MenuStateCustomGame simpleTask - B\n"); - MutexSafeWrapper safeMutex(callingThread->getMutexThreadObjectAccessor()); + MutexSafeWrapper safeMutex(callingThread->getMutexThreadObjectAccessor(),string(__FILE__) + "_" + intToStr(__LINE__)); bool republish = (needToRepublishToMasterserver == true && publishToServerInfo.size() != 0); needToRepublishToMasterserver = false; std::map newPublishToServerInfo = publishToServerInfo; @@ -1923,7 +1923,7 @@ void MenuStateCustomGame::simpleTask(BaseThread *callingThread) { std::string serverInfo = SystemFlags::getHTTP(request,handle); SystemFlags::cleanupHTTP(&handle); - MutexSafeWrapper safeMutexThreadOwner2(callingThread->getMutexThreadOwnerValid()); + MutexSafeWrapper safeMutexThreadOwner2(callingThread->getMutexThreadOwnerValid(),string(__FILE__) + "_" + intToStr(__LINE__)); if(callingThread->getQuitStatus() == true || safeMutexThreadOwner2.isValidMutex() == false) { return; } @@ -1951,7 +1951,7 @@ void MenuStateCustomGame::simpleTask(BaseThread *callingThread) { //printf("-=-=-=-=- IN MenuStateCustomGame simpleTask - D\n"); if(broadCastSettings == true) { - MutexSafeWrapper safeMutexThreadOwner2(callingThread->getMutexThreadOwnerValid()); + MutexSafeWrapper safeMutexThreadOwner2(callingThread->getMutexThreadOwnerValid(),string(__FILE__) + "_" + intToStr(__LINE__)); if(callingThread->getQuitStatus() == true || safeMutexThreadOwner2.isValidMutex() == false) { return; } @@ -1979,7 +1979,7 @@ void MenuStateCustomGame::simpleTask(BaseThread *callingThread) { //printf("-=-=-=-=- IN MenuStateCustomGame simpleTask - E\n"); if(needPing == true) { - MutexSafeWrapper safeMutexThreadOwner2(callingThread->getMutexThreadOwnerValid()); + MutexSafeWrapper safeMutexThreadOwner2(callingThread->getMutexThreadOwnerValid(),string(__FILE__) + "_" + intToStr(__LINE__)); if(callingThread->getQuitStatus() == true || safeMutexThreadOwner2.isValidMutex() == false) { return; } @@ -2674,7 +2674,7 @@ void MenuStateCustomGame::keyDown(char key) { activeInputLabel->setText(text); - MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL)); + MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__)); if(hasNetworkGameSettings() == true) { needToSetChangedGameSettings = true; lastSetChangedGameSettings = time(NULL); @@ -2731,7 +2731,7 @@ void MenuStateCustomGame::keyPress(char c) { text.insert(text.end()-1, c); activeInputLabel->setText(text); - MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL)); + MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__)); if(hasNetworkGameSettings() == true) { needToSetChangedGameSettings = true; lastSetChangedGameSettings = time(NULL); diff --git a/source/glest_game/menu/menu_state_masterserver.cpp b/source/glest_game/menu/menu_state_masterserver.cpp index b98db8c45..ae44d919f 100644 --- a/source/glest_game/menu/menu_state_masterserver.cpp +++ b/source/glest_game/menu/menu_state_masterserver.cpp @@ -265,7 +265,7 @@ MenuStateMasterserver::MenuStateMasterserver(Program *program, MainMenu *mainMen ircArgs.push_back(szIRCNick); ircArgs.push_back(IRC_CHANNEL); - MutexSafeWrapper safeMutexIRCPtr(&mutexIRCClient); + MutexSafeWrapper safeMutexIRCPtr(&mutexIRCClient,string(__FILE__) + "_" + intToStr(__LINE__)); ircClient = new IRCThread(ircArgs,this); ircClient->setUniqueID(__FILE__); ircClient->start(); @@ -288,7 +288,7 @@ void MenuStateMasterserver::setButtonLinePosition(int pos){ } void MenuStateMasterserver::IRC_CallbackEvent(IRCEventType evt, const char* origin, const char **params, unsigned int count) { - MutexSafeWrapper safeMutexIRCPtr(&mutexIRCClient); + MutexSafeWrapper safeMutexIRCPtr(&mutexIRCClient,string(__FILE__) + "_" + intToStr(__LINE__)); if(ircClient != NULL) { if(evt == IRC_evt_exitThread) { ircClient = NULL; @@ -313,7 +313,7 @@ void MenuStateMasterserver::IRC_CallbackEvent(IRCEventType evt, const char* orig void MenuStateMasterserver::cleanup() { SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); - MutexSafeWrapper safeMutex((updateFromMasterserverThread != NULL ? updateFromMasterserverThread->getMutexThreadObjectAccessor() : NULL)); + MutexSafeWrapper safeMutex((updateFromMasterserverThread != NULL ? updateFromMasterserverThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__)); needUpdateFromServer = false; safeMutex.ReleaseLock(); @@ -332,7 +332,7 @@ void MenuStateMasterserver::cleanup() { clearServerLines(); clearUserButtons(); - MutexSafeWrapper safeMutexIRCPtr(&mutexIRCClient); + MutexSafeWrapper safeMutexIRCPtr(&mutexIRCClient,string(__FILE__) + "_" + intToStr(__LINE__)); if(ircClient != NULL) { SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); @@ -395,7 +395,7 @@ void MenuStateMasterserver::mouseClick(int x, int y, MouseButton mouseButton){ else if(buttonRefresh.mouseClick(x, y)){ SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); - MutexSafeWrapper safeMutex((updateFromMasterserverThread != NULL ? updateFromMasterserverThread->getMutexThreadObjectAccessor() : NULL)); + MutexSafeWrapper safeMutex((updateFromMasterserverThread != NULL ? updateFromMasterserverThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__)); soundRenderer.playFx(coreData.getClickSoundB()); needUpdateFromServer = true; @@ -419,7 +419,7 @@ void MenuStateMasterserver::mouseClick(int x, int y, MouseButton mouseButton){ else if(buttonCreateGame.mouseClick(x, y)){ SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); - MutexSafeWrapper safeMutex((updateFromMasterserverThread != NULL ? updateFromMasterserverThread->getMutexThreadObjectAccessor() : NULL)); + MutexSafeWrapper safeMutex((updateFromMasterserverThread != NULL ? updateFromMasterserverThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__)); soundRenderer.playFx(coreData.getClickSoundB()); needUpdateFromServer = false; safeMutex.ReleaseLock(); @@ -434,12 +434,12 @@ void MenuStateMasterserver::mouseClick(int x, int y, MouseButton mouseButton){ SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); } else if(listBoxAutoRefresh.mouseClick(x, y)){ - MutexSafeWrapper safeMutex((updateFromMasterserverThread != NULL ? updateFromMasterserverThread->getMutexThreadObjectAccessor() : NULL)); + MutexSafeWrapper safeMutex((updateFromMasterserverThread != NULL ? updateFromMasterserverThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__)); soundRenderer.playFx(coreData.getClickSoundA()); autoRefreshTime=10*listBoxAutoRefresh.getSelectedItemIndex(); } else { - MutexSafeWrapper safeMutex((updateFromMasterserverThread != NULL ? updateFromMasterserverThread->getMutexThreadObjectAccessor() : NULL)); + MutexSafeWrapper safeMutex((updateFromMasterserverThread != NULL ? updateFromMasterserverThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__)); bool clicked=false; if(!clicked && serverScrollBar.getElementCount()!=0){ for(int i = serverScrollBar.getVisibleStart(); i <= serverScrollBar.getVisibleEnd(); ++i) { @@ -482,7 +482,7 @@ void MenuStateMasterserver::mouseClick(int x, int y, MouseButton mouseButton){ } void MenuStateMasterserver::mouseMove(int x, int y, const MouseState *ms){ - MutexSafeWrapper safeMutex((updateFromMasterserverThread != NULL ? updateFromMasterserverThread->getMutexThreadObjectAccessor() : NULL)); + MutexSafeWrapper safeMutex((updateFromMasterserverThread != NULL ? updateFromMasterserverThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__)); if (mainMessageBox.getEnabled()) { mainMessageBox.mouseMove(x, y); @@ -515,7 +515,7 @@ void MenuStateMasterserver::mouseMove(int x, int y, const MouseState *ms){ void MenuStateMasterserver::render(){ Renderer &renderer= Renderer::getInstance(); - MutexSafeWrapper safeMutex((updateFromMasterserverThread != NULL ? updateFromMasterserverThread->getMutexThreadObjectAccessor() : NULL)); + MutexSafeWrapper safeMutex((updateFromMasterserverThread != NULL ? updateFromMasterserverThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__)); if(mainMessageBox.getEnabled()) { renderer.renderMessageBox(&mainMessageBox); } @@ -548,7 +548,7 @@ void MenuStateMasterserver::render(){ renderer.renderLabel(&selectButton,&titleLabelColor); Lang &lang= Lang::getInstance(); - MutexSafeWrapper safeMutexIRCPtr(&mutexIRCClient); + MutexSafeWrapper safeMutexIRCPtr(&mutexIRCClient,string(__FILE__) + "_" + intToStr(__LINE__)); if(ircClient != NULL && ircClient->isConnected() == true && ircClient->getHasJoinedChannel() == true) { @@ -609,7 +609,7 @@ void MenuStateMasterserver::render(){ } void MenuStateMasterserver::update() { - MutexSafeWrapper safeMutex((updateFromMasterserverThread != NULL ? updateFromMasterserverThread->getMutexThreadObjectAccessor() : NULL)); + MutexSafeWrapper safeMutex((updateFromMasterserverThread != NULL ? updateFromMasterserverThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__)); if(autoRefreshTime!=0 && difftime(time(NULL),lastRefreshTimer) >= autoRefreshTime ) { needUpdateFromServer = true; lastRefreshTimer= time(NULL); @@ -637,7 +637,7 @@ void MenuStateMasterserver::update() { //console consoleIRC.update(); - MutexSafeWrapper safeMutexIRCPtr(&mutexIRCClient); + MutexSafeWrapper safeMutexIRCPtr(&mutexIRCClient,string(__FILE__) + "_" + intToStr(__LINE__)); if(ircClient != NULL) { std::vector nickList = ircClient->getNickList(); bool isNew=false; @@ -708,7 +708,7 @@ void MenuStateMasterserver::simpleTask(BaseThread *callingThread) { if(callingThread->getQuitStatus() == true) { return; } - MutexSafeWrapper safeMutex(callingThread->getMutexThreadObjectAccessor()); + MutexSafeWrapper safeMutex(callingThread->getMutexThreadObjectAccessor(),string(__FILE__) + "_" + intToStr(__LINE__)); bool needUpdate = needUpdateFromServer; if(needUpdate == true) { @@ -979,7 +979,7 @@ void MenuStateMasterserver::keyDown(char key) { //chatmanger only if connected to irc! if (chatManager.getEditEnabled() == true) { //printf("keyDown key [%d] chatManager.getText() [%s]\n",key,chatManager.getText().c_str()); - MutexSafeWrapper safeMutexIRCPtr(&mutexIRCClient); + MutexSafeWrapper safeMutexIRCPtr(&mutexIRCClient,string(__FILE__) + "_" + intToStr(__LINE__)); if (key == vkReturn && ircClient != NULL) { ircClient->SendIRCCmdMessage(IRC_CHANNEL, chatManager.getText()); } diff --git a/source/glest_game/network/connection_slot.cpp b/source/glest_game/network/connection_slot.cpp index b51208361..ace659e2a 100644 --- a/source/glest_game/network/connection_slot.cpp +++ b/source/glest_game/network/connection_slot.cpp @@ -61,7 +61,7 @@ void ConnectionSlotThread::signalUpdate(ConnectionSlotEvent *event) { //SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] event = %p\n",__FILE__,__FUNCTION__,__LINE__,event); if(event != NULL) { - MutexSafeWrapper safeMutex(&triggerIdMutex); + MutexSafeWrapper safeMutex(&triggerIdMutex,string(__FILE__) + "_" + intToStr(__LINE__)); eventList.push_back(*event); safeMutex.ReleaseLock(); } @@ -73,7 +73,7 @@ void ConnectionSlotThread::setTaskCompleted(int eventId) { //SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__); if(eventId > 0) { - MutexSafeWrapper safeMutex(&triggerIdMutex); + MutexSafeWrapper safeMutex(&triggerIdMutex,string(__FILE__) + "_" + intToStr(__LINE__)); //event->eventCompleted = true; for(int i = 0; i < eventList.size(); ++i) { ConnectionSlotEvent &slotEvent = eventList[i]; @@ -90,13 +90,13 @@ void ConnectionSlotThread::setTaskCompleted(int eventId) { } void ConnectionSlotThread::purgeAllEvents() { - MutexSafeWrapper safeMutex(&triggerIdMutex); + MutexSafeWrapper safeMutex(&triggerIdMutex,string(__FILE__) + "_" + intToStr(__LINE__)); eventList.clear(); safeMutex.ReleaseLock(); } void ConnectionSlotThread::setAllEventsCompleted() { - MutexSafeWrapper safeMutex(&triggerIdMutex); + MutexSafeWrapper safeMutex(&triggerIdMutex,string(__FILE__) + "_" + intToStr(__LINE__)); for(int i = 0; i < eventList.size(); ++i) { ConnectionSlotEvent &slotEvent = eventList[i]; if(slotEvent.eventCompleted == false) { @@ -107,7 +107,7 @@ void ConnectionSlotThread::setAllEventsCompleted() { } void ConnectionSlotThread::purgeCompletedEvents() { - MutexSafeWrapper safeMutex(&triggerIdMutex); + MutexSafeWrapper safeMutex(&triggerIdMutex,string(__FILE__) + "_" + intToStr(__LINE__)); //event->eventCompleted = true; for(int i = eventList.size() - 1; i >= 0; i--) { ConnectionSlotEvent &slotEvent = eventList[i]; @@ -130,7 +130,7 @@ bool ConnectionSlotThread::canShutdown(bool deleteSelfIfShutdownDelayed) { bool ConnectionSlotThread::isSignalCompleted(ConnectionSlotEvent *event) { //SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] slotIndex = %d\n",__FILE__,__FUNCTION__,__LINE__,slotIndex); - MutexSafeWrapper safeMutex(&triggerIdMutex); + MutexSafeWrapper safeMutex(&triggerIdMutex,string(__FILE__) + "_" + intToStr(__LINE__)); //bool result = (event != NULL ? event->eventCompleted : true); bool result = false; if(event != NULL) { @@ -172,7 +172,7 @@ void ConnectionSlotThread::execute() { //SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); - MutexSafeWrapper safeMutex(&triggerIdMutex); + MutexSafeWrapper safeMutex(&triggerIdMutex,string(__FILE__) + "_" + intToStr(__LINE__)); int eventCount = eventList.size(); if(eventCount > 0) { ConnectionSlotEvent eventCopy; @@ -293,13 +293,13 @@ void ConnectionSlot::update(bool checkForNewClients,int lockedSlotIndex) { // Is the listener socket ready to be read? if(checkForNewClients == true) { - SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] BEFORE accept new client connection, serverInterface->getOpenSlotCount() = %d\n",__FILE__,__FUNCTION__,serverInterface->getOpenSlotCount()); + SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] BEFORE accept new client connection, serverInterface->getOpenSlotCount() = %d\n",__FILE__,__FUNCTION__,__LINE__,serverInterface->getOpenSlotCount()); bool hasOpenSlots = (serverInterface->getOpenSlotCount() > 0); if(serverInterface->getServerSocket() != NULL && serverInterface->getServerSocket()->hasDataToRead() == true) { - SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] playerIndex = %d\n",__FILE__,__FUNCTION__,__LINE__,playerIndex); + SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] about to accept new client connection playerIndex = %d\n",__FILE__,__FUNCTION__,__LINE__,playerIndex); socket = serverInterface->getServerSocket()->accept(); - SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] playerIndex = %d\n",__FILE__,__FUNCTION__,__LINE__,playerIndex); + SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] called accept new client connection playerIndex = %d\n",__FILE__,__FUNCTION__,__LINE__,playerIndex); if(socket != NULL) { this->connectedTime = time(NULL); this->clearChatInfo(); @@ -309,7 +309,7 @@ void ConnectionSlot::update(bool checkForNewClients,int lockedSlotIndex) { this->receivedNetworkGameStatus = false; this->gotIntro = false; - MutexSafeWrapper safeMutexSlot(&mutexPendingNetworkCommandList,intToStr(__LINE__)); + MutexSafeWrapper safeMutexSlot(&mutexPendingNetworkCommandList,string(__FILE__) + "_" + intToStr(__LINE__)); this->vctPendingNetworkCommandList.clear(); safeMutexSlot.ReleaseLock(); @@ -426,7 +426,7 @@ void ConnectionSlot::update(bool checkForNewClients,int lockedSlotIndex) { lastReceiveCommandListTime = time(NULL); SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] currentFrameCount = %d\n",__FILE__,__FUNCTION__,__LINE__,currentFrameCount); - MutexSafeWrapper safeMutexSlot(&mutexPendingNetworkCommandList,intToStr(__LINE__)); + MutexSafeWrapper safeMutexSlot(&mutexPendingNetworkCommandList,string(__FILE__) + "_" + intToStr(__LINE__)); for(int i = 0; i < networkMessageCommandList.getCommandCount(); ++i) { vctPendingNetworkCommandList.push_back(*networkMessageCommandList.getCommand(i)); } @@ -682,8 +682,7 @@ void ConnectionSlot::update(bool checkForNewClients,int lockedSlotIndex) { if(gotIntro == true) { SwitchSetupRequest switchSetupRequest; if(receiveMessage(&switchSetupRequest)) { - Mutex *mutex = getServerSynchAccessor(); - if(mutex != NULL) mutex->p(); + MutexSafeWrapper safeMutex(getServerSynchAccessor(),string(__FILE__) + "_" + intToStr(__LINE__)); int factionIdx = switchSetupRequest.getCurrentFactionIndex(); if(serverInterface->getSwitchSetupRequests()[factionIdx] == NULL) { @@ -692,8 +691,6 @@ void ConnectionSlot::update(bool checkForNewClients,int lockedSlotIndex) { *(serverInterface->getSwitchSetupRequests()[factionIdx]) = switchSetupRequest; SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] factionIdx = %d, switchSetupRequest.getNetworkPlayerName() [%s] switchSetupRequest.getSwitchFlags() = %d\n",__FILE__,__FUNCTION__,__LINE__,factionIdx,switchSetupRequest.getNetworkPlayerName().c_str(),switchSetupRequest.getSwitchFlags()); - - if(mutex != NULL) mutex->v(); } } break; @@ -810,7 +807,7 @@ bool ConnectionSlot::updateCompleted(ConnectionSlotEvent *event) { } void ConnectionSlot::sendMessage(const NetworkMessage* networkMessage) { - MutexSafeWrapper safeMutex(&socketSynchAccessor); + MutexSafeWrapper safeMutex(&socketSynchAccessor,string(__FILE__) + "_" + intToStr(__LINE__)); NetworkInterface::sendMessage(networkMessage); } @@ -819,7 +816,7 @@ string ConnectionSlot::getHumanPlayerName(int index) { } vector ConnectionSlot::getPendingNetworkCommandList(bool clearList) { - MutexSafeWrapper safeMutexSlot(&mutexPendingNetworkCommandList,intToStr(__LINE__)); + MutexSafeWrapper safeMutexSlot(&mutexPendingNetworkCommandList,string(__FILE__) + "_" + intToStr(__LINE__)); vector ret = vctPendingNetworkCommandList; if(clearList == true) { vctPendingNetworkCommandList.clear(); @@ -830,7 +827,7 @@ vector ConnectionSlot::getPendingNetworkCommandList(bool clearLi } void ConnectionSlot::clearPendingNetworkCommandList() { - MutexSafeWrapper safeMutexSlot(&mutexPendingNetworkCommandList,intToStr(__LINE__)); + MutexSafeWrapper safeMutexSlot(&mutexPendingNetworkCommandList,string(__FILE__) + "_" + intToStr(__LINE__)); vctPendingNetworkCommandList.clear(); } diff --git a/source/glest_game/network/server_interface.cpp b/source/glest_game/network/server_interface.cpp index 04410dce1..6944900d7 100644 --- a/source/glest_game/network/server_interface.cpp +++ b/source/glest_game/network/server_interface.cpp @@ -107,7 +107,7 @@ ServerInterface::~ServerInterface() { exitServer = true; for(int i= 0; i < GameConstants::maxPlayers; ++i) { if(slots[i] != NULL) { - MutexSafeWrapper safeMutex(&slotAccessorMutexes[i],intToStr(__LINE__) + "_" + intToStr(i) + "_" + intToStr(i)); + MutexSafeWrapper safeMutex(&slotAccessorMutexes[i],string(__FILE__) + "_" + intToStr(__LINE__) + "_" + intToStr(i)); delete slots[i]; slots[i]=NULL; } @@ -125,7 +125,7 @@ ServerInterface::~ServerInterface() { delete ftpServer; ftpServer = NULL; } - MutexSafeWrapper safeMutex(&masterServerThreadAccessor,intToStr(__LINE__)); + MutexSafeWrapper safeMutex(&masterServerThreadAccessor,string(__FILE__) + "_" + intToStr(__LINE__)); delete publishToMasterserverThread; publishToMasterserverThread = NULL; safeMutex.ReleaseLock(); @@ -140,7 +140,7 @@ int ServerInterface::isValidClientType(uint32 clientIp) { int result = 0; for(int i= 0; exitServer == false && i < GameConstants::maxPlayers; ++i) { if(slots[i] != NULL) { - MutexSafeWrapper safeMutex(&slotAccessorMutexes[i],intToStr(__LINE__) + "_" + intToStr(i) + "_" + intToStr(i)); + MutexSafeWrapper safeMutex(&slotAccessorMutexes[i],string(__FILE__) + "_" + intToStr(__LINE__) + "_" + intToStr(i)); Socket *socket = slots[i]->getSocket(); if(socket != NULL) { @@ -162,14 +162,14 @@ void ServerInterface::addClientToServerIPAddress(uint32 clientIp, uint32 ServerI void ServerInterface::addSlot(int playerIndex) { SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); assert(playerIndex >= 0 && playerIndex < GameConstants::maxPlayers); - MutexSafeWrapper safeMutex(&serverSynchAccessor,intToStr(__LINE__)); + MutexSafeWrapper safeMutex(&serverSynchAccessor,string(__FILE__) + "_" + intToStr(__LINE__)); if(serverSocket.isPortBound() == false) { SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); serverSocket.bind(serverSocket.getBindPort()); } SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); - MutexSafeWrapper safeMutexSlot(&slotAccessorMutexes[playerIndex],intToStr(__LINE__) + "_" + intToStr(playerIndex)); + MutexSafeWrapper safeMutexSlot(&slotAccessorMutexes[playerIndex],string(__FILE__) + "_" + intToStr(__LINE__) + "_" + intToStr(playerIndex)); SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); ConnectionSlot *slot = slots[playerIndex]; if(slot != NULL) { @@ -195,9 +195,9 @@ bool ServerInterface::switchSlot(int fromPlayerIndex, int toPlayerIndex) { return false; } - MutexSafeWrapper safeMutex(&serverSynchAccessor,intToStr(__LINE__)); - MutexSafeWrapper safeMutexSlot(&slotAccessorMutexes[fromPlayerIndex],intToStr(__LINE__) + "_" + intToStr(fromPlayerIndex)); - MutexSafeWrapper safeMutexSlot2(&slotAccessorMutexes[toPlayerIndex],intToStr(__LINE__) + "_" + intToStr(toPlayerIndex)); + MutexSafeWrapper safeMutex(&serverSynchAccessor,string(__FILE__) + "_" + intToStr(__LINE__)); + MutexSafeWrapper safeMutexSlot(&slotAccessorMutexes[fromPlayerIndex],string(__FILE__) + "_" + intToStr(__LINE__) + "_" + intToStr(fromPlayerIndex)); + MutexSafeWrapper safeMutexSlot2(&slotAccessorMutexes[toPlayerIndex],string(__FILE__) + "_" + intToStr(__LINE__) + "_" + intToStr(toPlayerIndex)); if(slots[toPlayerIndex] != NULL && slots[toPlayerIndex] != NULL && slots[toPlayerIndex]->isConnected() == false) { slots[fromPlayerIndex]->setPlayerIndex(toPlayerIndex); @@ -224,11 +224,11 @@ bool ServerInterface::switchSlot(int fromPlayerIndex, int toPlayerIndex) { void ServerInterface::removeSlot(int playerIndex, int lockedSlotIndex) { SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] playerIndex = %d, lockedSlotIndex = %d\n",__FILE__,__FUNCTION__,__LINE__,playerIndex,lockedSlotIndex); - MutexSafeWrapper safeMutex(&serverSynchAccessor,intToStr(__LINE__)); - MutexSafeWrapper safeMutexSlot(NULL,intToStr(__LINE__) + "_" + intToStr(playerIndex)); + MutexSafeWrapper safeMutex(&serverSynchAccessor,string(__FILE__) + "_" + intToStr(__LINE__)); + MutexSafeWrapper safeMutexSlot(NULL,string(__FILE__) + "_" + intToStr(__LINE__) + "_" + intToStr(playerIndex)); if(playerIndex != lockedSlotIndex) { SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] playerIndex = %d, lockedSlotIndex = %d\n",__FILE__,__FUNCTION__,__LINE__,playerIndex,lockedSlotIndex); - safeMutexSlot.setMutex(&slotAccessorMutexes[playerIndex],intToStr(__LINE__) + string("_") + intToStr(playerIndex)); + safeMutexSlot.setMutex(&slotAccessorMutexes[playerIndex],string(__FILE__) + "_" + intToStr(__LINE__) + string("_") + intToStr(playerIndex)); } ConnectionSlot *slot = slots[playerIndex]; bool notifyDisconnect = false; @@ -274,7 +274,7 @@ ConnectionSlot *ServerInterface::getSlot(int playerIndex) { bool ServerInterface::hasClientConnection() { bool result = false; for(int i= 0; exitServer == false && i < GameConstants::maxPlayers; ++i) { - MutexSafeWrapper safeMutexSlot(&slotAccessorMutexes[i],intToStr(__LINE__) + "_" + intToStr(i)); + MutexSafeWrapper safeMutexSlot(&slotAccessorMutexes[i],string(__FILE__) + "_" + intToStr(__LINE__) + "_" + intToStr(i)); if(slots[i] != NULL && slots[i]->isConnected() == true) { result = true; break; @@ -286,7 +286,7 @@ bool ServerInterface::hasClientConnection() { int ServerInterface::getConnectedSlotCount() { int connectedSlotCount = 0; for(int i= 0; exitServer == false && i < GameConstants::maxPlayers; ++i) { - MutexSafeWrapper safeMutexSlot(&slotAccessorMutexes[i],intToStr(__LINE__) + "_" + intToStr(i)); + MutexSafeWrapper safeMutexSlot(&slotAccessorMutexes[i],string(__FILE__) + "_" + intToStr(__LINE__) + "_" + intToStr(i)); if(slots[i] != NULL) { ++connectedSlotCount; } @@ -333,7 +333,7 @@ void ServerInterface::updateSlot(ConnectionSlotEvent *event) { ConnectionSlot *connectionSlot = NULL; MutexSafeWrapper safeMutexSlot(NULL); if(event->triggerId >= 0 && event->triggerId < GameConstants::maxPlayers) { - safeMutexSlot.setMutex(&slotAccessorMutexes[event->triggerId],intToStr(__LINE__) + "_" + intToStr(event->triggerId)); + safeMutexSlot.setMutex(&slotAccessorMutexes[event->triggerId],string(__FILE__) + "_" + intToStr(__LINE__) + "_" + intToStr(event->triggerId)); connectionSlot = slots[event->triggerId]; } else { @@ -492,7 +492,7 @@ bool ServerInterface::signalClientReceiveCommands(ConnectionSlot *connectionSlot void ServerInterface::updateSocketTriggeredList(std::map & socketTriggeredList) { for(int i= 0; exitServer == false && i < GameConstants::maxPlayers; ++i) { - MutexSafeWrapper safeMutexSlot(&slotAccessorMutexes[i],intToStr(__LINE__) + "_" + intToStr(i)); + MutexSafeWrapper safeMutexSlot(&slotAccessorMutexes[i],string(__FILE__) + "_" + intToStr(__LINE__) + "_" + intToStr(i)); ConnectionSlot* connectionSlot= slots[i]; if(connectionSlot != NULL && connectionSlot->getSocket() != NULL && slots[i]->getSocket()->isSocketValid() == true) { @@ -503,7 +503,7 @@ void ServerInterface::updateSocketTriggeredList(std::map & void ServerInterface::validateConnectedClients() { for(int i= 0; exitServer == false && i < GameConstants::maxPlayers; ++i) { - MutexSafeWrapper safeMutexSlot(&slotAccessorMutexes[i],intToStr(__LINE__) + "_" + intToStr(i)); + MutexSafeWrapper safeMutexSlot(&slotAccessorMutexes[i],string(__FILE__) + "_" + intToStr(__LINE__) + "_" + intToStr(i)); ConnectionSlot* connectionSlot = slots[i]; if(connectionSlot != NULL) { @@ -517,7 +517,7 @@ void ServerInterface::signalClientsToRecieveData(std::map std::map & mapSlotSignalledList) { bool checkForNewClients = true; for(int i= 0; exitServer == false && i < GameConstants::maxPlayers; ++i) { - MutexSafeWrapper safeMutexSlot(&slotAccessorMutexes[i],intToStr(__LINE__) + "_" + intToStr(i)); + MutexSafeWrapper safeMutexSlot(&slotAccessorMutexes[i],string(__FILE__) + "_" + intToStr(__LINE__) + "_" + intToStr(i)); ConnectionSlot* connectionSlot = slots[i]; bool socketTriggered = false; @@ -540,7 +540,7 @@ void ServerInterface::checkForCompletedClients(std::map & mapSlotSigna threadsDone = true; // Examine all threads for completion of delegation for(int i= 0; exitServer == false && i < GameConstants::maxPlayers; ++i) { - MutexSafeWrapper safeMutexSlot(&slotAccessorMutexes[i],intToStr(__LINE__) + string("_") + intToStr(i)); + MutexSafeWrapper safeMutexSlot(&slotAccessorMutexes[i],string(__FILE__) + "_" + intToStr(__LINE__) + string("_") + intToStr(i)); ConnectionSlot* connectionSlot = slots[i]; if(connectionSlot != NULL && mapSlotSignalledList[i] == true && slotsCompleted.find(i) == slotsCompleted.end()) { @@ -591,7 +591,7 @@ void ServerInterface::checForLaggingClients(std::map &mapSlotSignalled threadsDone = true; // Examine all threads for completion of delegation for(int i= 0; exitServer == false && i < GameConstants::maxPlayers; ++i) { - MutexSafeWrapper safeMutexSlot(&slotAccessorMutexes[i],intToStr(__LINE__) + "_" + intToStr(i)); + MutexSafeWrapper safeMutexSlot(&slotAccessorMutexes[i],string(__FILE__) + "_" + intToStr(__LINE__) + "_" + intToStr(i)); ConnectionSlot* connectionSlot = slots[i]; if(connectionSlot != NULL && mapSlotSignalledList[i] == true && slotsCompleted.find(i) == slotsCompleted.end()) { @@ -668,7 +668,7 @@ void ServerInterface::checForLaggingClients(std::map &mapSlotSignalled void ServerInterface::executeNetworkCommandsFromClients() { if(gameHasBeenInitiated == true) { for(int i= 0; exitServer == false && i < GameConstants::maxPlayers; ++i) { - MutexSafeWrapper safeMutexSlot(&slotAccessorMutexes[i],intToStr(__LINE__) + "_" + intToStr(i)); + MutexSafeWrapper safeMutexSlot(&slotAccessorMutexes[i],string(__FILE__) + "_" + intToStr(__LINE__) + "_" + intToStr(i)); ConnectionSlot* connectionSlot= slots[i]; if(connectionSlot != NULL && connectionSlot->isConnected() == true) { vector pendingList = connectionSlot->getPendingNetworkCommandList(true); @@ -685,7 +685,7 @@ void ServerInterface::executeNetworkCommandsFromClients() { void ServerInterface::dispatchPendingChatMessages(std::vector &errorMsgList) { for(int i= 0; exitServer == false && i < GameConstants::maxPlayers; ++i) { - MutexSafeWrapper safeMutexSlot(&slotAccessorMutexes[i],intToStr(__LINE__) + "_" + intToStr(i)); + MutexSafeWrapper safeMutexSlot(&slotAccessorMutexes[i],string(__FILE__) + "_" + intToStr(__LINE__) + "_" + intToStr(i)); ConnectionSlot* connectionSlot= slots[i]; if(connectionSlot != NULL && connectionSlot->getChatTextList().empty() == false) { @@ -940,7 +940,7 @@ void ServerInterface::waitUntilReady(Checksum *checksum) { vector waitingForHosts; allReady= true; for(int i= 0; exitServer == false && i < GameConstants::maxPlayers; ++i) { - MutexSafeWrapper safeMutexSlot(&slotAccessorMutexes[i],intToStr(__LINE__) + "_" + intToStr(i)); + MutexSafeWrapper safeMutexSlot(&slotAccessorMutexes[i],string(__FILE__) + "_" + intToStr(__LINE__) + "_" + intToStr(i)); ConnectionSlot* connectionSlot= slots[i]; if(connectionSlot != NULL && connectionSlot->isConnected() == true) { if(connectionSlot->isReady() == false) { @@ -1001,7 +1001,7 @@ void ServerInterface::waitUntilReady(Checksum *checksum) { try { //send ready message after, so clients start delayed for(int i= 0; exitServer == false && i < GameConstants::maxPlayers; ++i) { - MutexSafeWrapper safeMutexSlot(&slotAccessorMutexes[i],intToStr(__LINE__) + "_" + intToStr(i)); + MutexSafeWrapper safeMutexSlot(&slotAccessorMutexes[i],string(__FILE__) + "_" + intToStr(__LINE__) + "_" + intToStr(i)); ConnectionSlot* connectionSlot= slots[i]; if(connectionSlot != NULL && connectionSlot->isConnected() == true) { NetworkMessageReady networkMessageReady(checksum->getSum()); @@ -1020,7 +1020,7 @@ void ServerInterface::waitUntilReady(Checksum *checksum) { } void ServerInterface::processBroadCastMessageQueue() { - MutexSafeWrapper safeMutexSlot(&broadcastMessageQueueThreadAccessor,intToStr(__LINE__)); + MutexSafeWrapper safeMutexSlot(&broadcastMessageQueueThreadAccessor,string(__FILE__) + "_" + intToStr(__LINE__)); if(broadcastMessageQueue.size() > 0) { SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] broadcastMessageQueue.size() = %d\n",__FILE__,__FUNCTION__,__LINE__,broadcastMessageQueue.size()); for(int i = 0; i < broadcastMessageQueue.size(); ++i) { @@ -1036,7 +1036,7 @@ void ServerInterface::processBroadCastMessageQueue() { } void ServerInterface::queueBroadcastMessage(const NetworkMessage *networkMessage, int excludeSlot) { - MutexSafeWrapper safeMutexSlot(&broadcastMessageQueueThreadAccessor,intToStr(__LINE__)); + MutexSafeWrapper safeMutexSlot(&broadcastMessageQueueThreadAccessor,string(__FILE__) + "_" + intToStr(__LINE__)); pair item; item.first = networkMessage; item.second = excludeSlot; @@ -1044,7 +1044,7 @@ void ServerInterface::queueBroadcastMessage(const NetworkMessage *networkMessage } void ServerInterface::processTextMessageQueue() { - MutexSafeWrapper safeMutexSlot(&textMessageQueueThreadAccessor,intToStr(__LINE__)); + MutexSafeWrapper safeMutexSlot(&textMessageQueueThreadAccessor,string(__FILE__) + "_" + intToStr(__LINE__)); if(textMessageQueue.size() > 0) { SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] textMessageQueue.size() = %d\n",__FILE__,__FUNCTION__,__LINE__,textMessageQueue.size()); for(int i = 0; i < textMessageQueue.size(); ++i) { @@ -1056,7 +1056,7 @@ void ServerInterface::processTextMessageQueue() { } void ServerInterface::queueTextMessage(const string & text, int teamIndex, bool echoLocal) { - MutexSafeWrapper safeMutexSlot(&textMessageQueueThreadAccessor,intToStr(__LINE__)); + MutexSafeWrapper safeMutexSlot(&textMessageQueueThreadAccessor,string(__FILE__) + "_" + intToStr(__LINE__)); TextMessageQueue item; item.text = text; item.teamIndex = teamIndex; @@ -1093,7 +1093,7 @@ string ServerInterface::getNetworkStatus() { Lang &lang = Lang::getInstance(); string str=""; for(int i= 0; exitServer == false && i < GameConstants::maxPlayers; ++i) { - MutexSafeWrapper safeMutexSlot(&slotAccessorMutexes[i],intToStr(__LINE__) + "_" + intToStr(i)); + MutexSafeWrapper safeMutexSlot(&slotAccessorMutexes[i],string(__FILE__) + "_" + intToStr(__LINE__) + "_" + intToStr(i)); ConnectionSlot* connectionSlot= slots[i]; str+= intToStr(i)+ ": "; @@ -1122,7 +1122,7 @@ bool ServerInterface::launchGame(const GameSettings *gameSettings) { bool bOkToStart = true; SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); for(int i= 0; exitServer == false && i < GameConstants::maxPlayers; ++i) { - MutexSafeWrapper safeMutexSlot(&slotAccessorMutexes[i],intToStr(__LINE__) + "_" + intToStr(i)); + MutexSafeWrapper safeMutexSlot(&slotAccessorMutexes[i],string(__FILE__) + "_" + intToStr(__LINE__) + "_" + intToStr(i)); ConnectionSlot *connectionSlot= slots[i]; if(connectionSlot != NULL && connectionSlot->getAllowDownloadDataSynch() == true && @@ -1145,7 +1145,7 @@ bool ServerInterface::launchGame(const GameSettings *gameSettings) { SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] needToRepublishToMasterserver = %d\n",__FILE__,__FUNCTION__,__LINE__,needToRepublishToMasterserver); - MutexSafeWrapper safeMutex(&masterServerThreadAccessor,intToStr(__LINE__)); + MutexSafeWrapper safeMutex(&masterServerThreadAccessor,string(__FILE__) + "_" + intToStr(__LINE__)); delete publishToMasterserverThread; publishToMasterserverThread = NULL; lastMasterserverHeartbeatTime = 0; @@ -1180,7 +1180,7 @@ bool ServerInterface::launchGame(const GameSettings *gameSettings) { void ServerInterface::broadcastGameSetup(const GameSettings *gameSettings) { SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__); - MutexSafeWrapper safeMutex(&serverSynchAccessor,intToStr(__LINE__)); + MutexSafeWrapper safeMutex(&serverSynchAccessor,string(__FILE__) + "_" + intToStr(__LINE__)); NetworkMessageLaunch networkMessageLaunch(gameSettings, nmtBroadCastSetup); broadcastMessage(&networkMessageLaunch); SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__); @@ -1190,7 +1190,7 @@ void ServerInterface::broadcastMessage(const NetworkMessage *networkMessage, int try { SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); - MutexSafeWrapper safeMutexSlotBroadCastAccessor(&inBroadcastMessageThreadAccessor,intToStr(__LINE__)); + MutexSafeWrapper safeMutexSlotBroadCastAccessor(&inBroadcastMessageThreadAccessor,string(__FILE__) + "_" + intToStr(__LINE__)); if(inBroadcastMessage == true && dynamic_cast(networkMessage) != NULL) { safeMutexSlotBroadCastAccessor.ReleaseLock(); const NetworkMessageText *txtMsg = dynamic_cast(networkMessage); @@ -1204,10 +1204,10 @@ void ServerInterface::broadcastMessage(const NetworkMessage *networkMessage, int } for(int i= 0; exitServer == false && i < GameConstants::maxPlayers; ++i) { - MutexSafeWrapper safeMutexSlot(NULL,intToStr(__LINE__) + "_" + intToStr(i)); + MutexSafeWrapper safeMutexSlot(NULL,string(__FILE__) + "_" + intToStr(__LINE__) + "_" + intToStr(i)); if(i != lockedSlotIndex) { SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] i = %d, lockedSlotIndex = %d\n",__FILE__,__FUNCTION__,__LINE__,i,lockedSlotIndex); - safeMutexSlot.setMutex(&slotAccessorMutexes[i],intToStr(__LINE__) + "_" + intToStr(i)); + safeMutexSlot.setMutex(&slotAccessorMutexes[i],string(__FILE__) + "_" + intToStr(__LINE__) + "_" + intToStr(i)); } ConnectionSlot* connectionSlot= slots[i]; @@ -1242,7 +1242,7 @@ void ServerInterface::broadcastMessage(const NetworkMessage *networkMessage, int SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] ERROR [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); - MutexSafeWrapper safeMutexSlotBroadCastAccessor(&inBroadcastMessageThreadAccessor,intToStr(__LINE__)); + MutexSafeWrapper safeMutexSlotBroadCastAccessor(&inBroadcastMessageThreadAccessor,string(__FILE__) + "_" + intToStr(__LINE__)); inBroadcastMessage = false; safeMutexSlotBroadCastAccessor.ReleaseLock(); @@ -1255,7 +1255,7 @@ void ServerInterface::broadcastMessageToConnectedClients(const NetworkMessage *n SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__); try { for(int i= 0; exitServer == false && i < GameConstants::maxPlayers; ++i) { - MutexSafeWrapper safeMutexSlot(&slotAccessorMutexes[i],intToStr(__LINE__) + "_" + intToStr(i)); + MutexSafeWrapper safeMutexSlot(&slotAccessorMutexes[i],string(__FILE__) + "_" + intToStr(__LINE__) + "_" + intToStr(i)); ConnectionSlot *connectionSlot= slots[i]; if(i != excludeSlot && connectionSlot != NULL) { @@ -1304,7 +1304,7 @@ int ServerInterface::getOpenSlotCount() { void ServerInterface::setGameSettings(GameSettings *serverGameSettings, bool waitForClientAck) { SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] START gameSettingsUpdateCount = %d, waitForClientAck = %d\n",__FILE__,__FUNCTION__,gameSettingsUpdateCount,waitForClientAck); - MutexSafeWrapper safeMutex(&serverSynchAccessor,intToStr(__LINE__)); + MutexSafeWrapper safeMutex(&serverSynchAccessor,string(__FILE__) + "_" + intToStr(__LINE__)); gameSettings = *serverGameSettings; if(getAllowGameDataSynchCheck() == true) { if(waitForClientAck == true && gameSettingsUpdateCount > 0) { @@ -1315,7 +1315,7 @@ void ServerInterface::setGameSettings(GameSettings *serverGameSettings, bool wai while(gotAckFromAllClients == false && difftime(time(NULL),tStart) <= 5) { gotAckFromAllClients = true; for(int i= 0; exitServer == false && i < GameConstants::maxPlayers; ++i) { - MutexSafeWrapper safeMutexSlot(&slotAccessorMutexes[i],intToStr(__LINE__) + "_" + intToStr(i)); + MutexSafeWrapper safeMutexSlot(&slotAccessorMutexes[i],string(__FILE__) + "_" + intToStr(__LINE__) + "_" + intToStr(i)); ConnectionSlot *connectionSlot = slots[i]; if(connectionSlot != NULL && connectionSlot->isConnected()) { if(connectionSlot->getReceivedNetworkGameStatus() == false) { @@ -1329,7 +1329,7 @@ void ServerInterface::setGameSettings(GameSettings *serverGameSettings, bool wai } for(int i= 0; exitServer == false && i < GameConstants::maxPlayers; ++i) { - MutexSafeWrapper safeMutexSlot(&slotAccessorMutexes[i],intToStr(__LINE__) + "_" + intToStr(i)); + MutexSafeWrapper safeMutexSlot(&slotAccessorMutexes[i],string(__FILE__) + "_" + intToStr(__LINE__) + "_" + intToStr(i)); ConnectionSlot *connectionSlot = slots[i]; if(connectionSlot != NULL && connectionSlot->isConnected()) { connectionSlot->setReceivedNetworkGameStatus(false); @@ -1347,7 +1347,7 @@ void ServerInterface::setGameSettings(GameSettings *serverGameSettings, bool wai while(gotAckFromAllClients == false && difftime(time(NULL),tStart) <= 5) { gotAckFromAllClients = true; for(int i= 0; exitServer == false && i < GameConstants::maxPlayers; ++i) { - MutexSafeWrapper safeMutexSlot(&slotAccessorMutexes[i],intToStr(__LINE__) + "_" + intToStr(i)); + MutexSafeWrapper safeMutexSlot(&slotAccessorMutexes[i],string(__FILE__) + "_" + intToStr(__LINE__) + "_" + intToStr(i)); ConnectionSlot *connectionSlot = slots[i]; if(connectionSlot != NULL && connectionSlot->isConnected()) { if(connectionSlot->getReceivedNetworkGameStatus() == false) { @@ -1396,7 +1396,7 @@ std::map ServerInterface::publishToMasterserver() { std::map < string, string > publishToServerInfo; SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__); for(int i= 0; exitServer == false && i < GameConstants::maxPlayers; ++i) { - MutexSafeWrapper safeMutexSlot(&slotAccessorMutexes[i],intToStr(__LINE__) + "_" + intToStr(i)); + MutexSafeWrapper safeMutexSlot(&slotAccessorMutexes[i],string(__FILE__) + "_" + intToStr(__LINE__) + "_" + intToStr(i)); if(slots[i] != NULL) { slotCountUsed++; slotCountHumans++; @@ -1430,7 +1430,7 @@ std::map ServerInterface::publishToMasterserver() { } void ServerInterface::simpleTask(BaseThread *callingThread) { - MutexSafeWrapper safeMutex(&masterServerThreadAccessor,intToStr(__LINE__)); + MutexSafeWrapper safeMutex(&masterServerThreadAccessor,string(__FILE__) + "_" + intToStr(__LINE__)); if(difftime(time(NULL),lastMasterserverHeartbeatTime) >= MASTERSERVER_HEARTBEAT_GAME_STATUS_SECONDS) { SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__); diff --git a/source/glest_game/sound/sound_renderer.cpp b/source/glest_game/sound/sound_renderer.cpp index e298ca063..0db49e991 100644 --- a/source/glest_game/sound/sound_renderer.cpp +++ b/source/glest_game/sound/sound_renderer.cpp @@ -55,7 +55,7 @@ bool SoundRenderer::init(Window *window) { stopAllSounds(); - MutexSafeWrapper safeMutex(NULL); + MutexSafeWrapper safeMutex(NULL,string(__FILE__) + "_" + intToStr(__LINE__)); if(runThreadSafe == true) { safeMutex.setMutex(&mutex); } @@ -96,7 +96,7 @@ SoundRenderer::~SoundRenderer() { SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__); - MutexSafeWrapper safeMutex(NULL); + MutexSafeWrapper safeMutex(NULL,string(__FILE__) + "_" + intToStr(__LINE__)); if(runThreadSafe == true) { safeMutex.setMutex(&mutex); } @@ -113,7 +113,7 @@ SoundRenderer &SoundRenderer::getInstance() { void SoundRenderer::update() { if(soundPlayer != NULL) { - MutexSafeWrapper safeMutex(NULL); + MutexSafeWrapper safeMutex(NULL,string(__FILE__) + "_" + intToStr(__LINE__)); if(runThreadSafe == true) { safeMutex.setMutex(&mutex); } @@ -128,7 +128,7 @@ void SoundRenderer::playMusic(StrSound *strSound) { strSound->setVolume(musicVolume); strSound->restart(); if(soundPlayer != NULL) { - MutexSafeWrapper safeMutex(NULL); + MutexSafeWrapper safeMutex(NULL,string(__FILE__) + "_" + intToStr(__LINE__)); if(runThreadSafe == true) { safeMutex.setMutex(&mutex); } @@ -146,7 +146,7 @@ void SoundRenderer::setMusicVolume(StrSound *strSound) { void SoundRenderer::stopMusic(StrSound *strSound) { if(soundPlayer != NULL) { - MutexSafeWrapper safeMutex(NULL); + MutexSafeWrapper safeMutex(NULL,string(__FILE__) + "_" + intToStr(__LINE__)); if(runThreadSafe == true) { safeMutex.setMutex(&mutex); } @@ -172,7 +172,7 @@ void SoundRenderer::playFx(StaticSound *staticSound, Vec3f soundPos, Vec3f camPo staticSound->setVolume(correctedVol); if(soundPlayer != NULL) { - MutexSafeWrapper safeMutex(NULL); + MutexSafeWrapper safeMutex(NULL,string(__FILE__) + "_" + intToStr(__LINE__)); if(runThreadSafe == true) { safeMutex.setMutex(&mutex); } @@ -187,7 +187,7 @@ void SoundRenderer::playFx(StaticSound *staticSound) { if(staticSound!=NULL){ staticSound->setVolume(fxVolume); if(soundPlayer != NULL) { - MutexSafeWrapper safeMutex(NULL); + MutexSafeWrapper safeMutex(NULL,string(__FILE__) + "_" + intToStr(__LINE__)); if(runThreadSafe == true) { safeMutex.setMutex(&mutex); } @@ -203,7 +203,7 @@ void SoundRenderer::playAmbient(StrSound *strSound) { if(strSound != NULL) { strSound->setVolume(ambientVolume); if(soundPlayer != NULL) { - MutexSafeWrapper safeMutex(NULL); + MutexSafeWrapper safeMutex(NULL,string(__FILE__) + "_" + intToStr(__LINE__)); if(runThreadSafe == true) { safeMutex.setMutex(&mutex); } @@ -215,7 +215,7 @@ void SoundRenderer::playAmbient(StrSound *strSound) { void SoundRenderer::stopAmbient(StrSound *strSound) { if(soundPlayer != NULL) { - MutexSafeWrapper safeMutex(NULL); + MutexSafeWrapper safeMutex(NULL,string(__FILE__) + "_" + intToStr(__LINE__)); if(runThreadSafe == true) { safeMutex.setMutex(&mutex); } @@ -228,7 +228,7 @@ void SoundRenderer::stopAmbient(StrSound *strSound) { void SoundRenderer::stopAllSounds() { if(soundPlayer != NULL) { - MutexSafeWrapper safeMutex(NULL); + MutexSafeWrapper safeMutex(NULL,string(__FILE__) + "_" + intToStr(__LINE__)); if(runThreadSafe == true) { safeMutex.setMutex(&mutex); } diff --git a/source/shared_lib/include/platform/sdl/thread.h b/source/shared_lib/include/platform/sdl/thread.h index 47644fa21..ccc94242f 100644 --- a/source/shared_lib/include/platform/sdl/thread.h +++ b/source/shared_lib/include/platform/sdl/thread.h @@ -15,17 +15,22 @@ #include #include #include +#include "platform_common.h" +//#include "util.h" #include "leak_dumper.h" //#define DEBUG_MUTEXES +//#define DEBUG_PERFORMANCE_MUTEXES // ===================================================== // class Thread // ===================================================== using namespace std; +using namespace Shared::PlatformCommon; -namespace Shared{ namespace Platform{ + +namespace Shared { namespace Platform { class Thread{ public: @@ -75,6 +80,10 @@ class MutexSafeWrapper { protected: Mutex *mutex; string ownerId; +#ifdef DEBUG_PERFORMANCE_MUTEXES + Chrono chrono; +#endif + public: MutexSafeWrapper(Mutex *mutex,string ownerId="") { @@ -103,8 +112,17 @@ public: } #endif +#ifdef DEBUG_PERFORMANCE_MUTEXES + chrono.start(); +#endif + this->mutex->p(); +#ifdef DEBUG_PERFORMANCE_MUTEXES + if(chrono.getMillis() > 5) printf("In [%s::%s Line: %d] MUTEX LOCK took msecs: %lld, this->mutex->getRefCount() = %d ownerId [%s]\n",__FILE__,__FUNCTION__,__LINE__,(long long int)chrono.getMillis(),this->mutex->getRefCount(),ownerId.c_str()); + chrono.start(); +#endif + #ifdef DEBUG_MUTEXES if(ownerId != "") { printf("Locked Mutex [%s] refCount: %d\n",ownerId.c_str(),this->mutex->getRefCount()); @@ -122,6 +140,10 @@ public: this->mutex->v(); +#ifdef DEBUG_PERFORMANCE_MUTEXES + if(chrono.getMillis() > 100) printf("In [%s::%s Line: %d] MUTEX UNLOCKED and held locked for msecs: %lld, this->mutex->getRefCount() = %d ownerId [%s]\n",__FILE__,__FUNCTION__,__LINE__,(long long int)chrono.getMillis(),this->mutex->getRefCount(),ownerId.c_str()); +#endif + #ifdef DEBUG_MUTEXES if(ownerId != "") { printf("UnLocked Mutex [%s] refCount: %d\n",ownerId.c_str(),this->mutex->getRefCount()); diff --git a/source/shared_lib/sources/platform/common/base_thread.cpp b/source/shared_lib/sources/platform/common/base_thread.cpp index 4e6226740..e5730f341 100644 --- a/source/shared_lib/sources/platform/common/base_thread.cpp +++ b/source/shared_lib/sources/platform/common/base_thread.cpp @@ -13,6 +13,7 @@ #include "base_thread.h" #include "platform_common.h" #include "util.h" +#include "conversion.h" #include using namespace Shared::Util; @@ -48,14 +49,14 @@ Mutex * BaseThread::getMutexThreadOwnerValid() { } void BaseThread::setThreadOwnerValid(bool value) { - MutexSafeWrapper safeMutex(&mutexThreadOwnerValid); + MutexSafeWrapper safeMutex(&mutexThreadOwnerValid,string(__FILE__) + "_" + intToStr(__LINE__)); threadOwnerValid = value; safeMutex.ReleaseLock(); } bool BaseThread::getThreadOwnerValid() { bool ret = false; - MutexSafeWrapper safeMutex(&mutexThreadOwnerValid); + MutexSafeWrapper safeMutex(&mutexThreadOwnerValid,string(__FILE__) + "_" + intToStr(__LINE__)); ret = threadOwnerValid; safeMutex.ReleaseLock(); @@ -73,7 +74,7 @@ void BaseThread::signalQuit() { void BaseThread::setQuitStatus(bool value) { SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s]\n",__FILE__,__FUNCTION__,__LINE__,uniqueID.c_str()); - MutexSafeWrapper safeMutex(&mutexQuit); + MutexSafeWrapper safeMutex(&mutexQuit,string(__FILE__) + "_" + intToStr(__LINE__)); quit = value; safeMutex.ReleaseLock(); @@ -84,7 +85,7 @@ bool BaseThread::getQuitStatus() { //SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); bool retval = false; - MutexSafeWrapper safeMutex(&mutexQuit); + MutexSafeWrapper safeMutex(&mutexQuit,string(__FILE__) + "_" + intToStr(__LINE__)); retval = quit; safeMutex.ReleaseLock(); @@ -95,7 +96,7 @@ bool BaseThread::getQuitStatus() { bool BaseThread::getHasBeginExecution() { bool retval = false; - MutexSafeWrapper safeMutex(&mutexBeginExecution); + MutexSafeWrapper safeMutex(&mutexBeginExecution,string(__FILE__) + "_" + intToStr(__LINE__)); retval = hasBeginExecution; safeMutex.ReleaseLock(); @@ -107,7 +108,7 @@ bool BaseThread::getHasBeginExecution() { void BaseThread::setHasBeginExecution(bool value) { SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s]\n",__FILE__,__FUNCTION__,__LINE__,uniqueID.c_str()); - MutexSafeWrapper safeMutex(&mutexBeginExecution); + MutexSafeWrapper safeMutex(&mutexBeginExecution,string(__FILE__) + "_" + intToStr(__LINE__)); hasBeginExecution = value; safeMutex.ReleaseLock(); @@ -118,7 +119,7 @@ bool BaseThread::getRunningStatus() { //SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s]\n",__FILE__,__FUNCTION__,__LINE__,uniqueID.c_str()); bool retval = false; - MutexSafeWrapper safeMutex(&mutexRunning); + MutexSafeWrapper safeMutex(&mutexRunning,string(__FILE__) + "_" + intToStr(__LINE__)); retval = running; safeMutex.ReleaseLock(); @@ -134,7 +135,7 @@ bool BaseThread::getRunningStatus() { void BaseThread::setRunningStatus(bool value) { SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s] value = %d\n",__FILE__,__FUNCTION__,__LINE__,uniqueID.c_str(),value); - MutexSafeWrapper safeMutex(&mutexRunning); + MutexSafeWrapper safeMutex(&mutexRunning,string(__FILE__) + "_" + intToStr(__LINE__)); running = value; setHasBeginExecution(true); safeMutex.ReleaseLock(); @@ -143,14 +144,14 @@ void BaseThread::setRunningStatus(bool value) { } void BaseThread::setExecutingTask(bool value) { - MutexSafeWrapper safeMutex(&mutexExecutingTask); + MutexSafeWrapper safeMutex(&mutexExecutingTask,string(__FILE__) + "_" + intToStr(__LINE__)); executingTask = value; safeMutex.ReleaseLock(); } bool BaseThread::getExecutingTask() { bool retval = false; - MutexSafeWrapper safeMutex(&mutexExecutingTask); + MutexSafeWrapper safeMutex(&mutexExecutingTask,string(__FILE__) + "_" + intToStr(__LINE__)); retval = executingTask; safeMutex.ReleaseLock(); @@ -159,7 +160,7 @@ bool BaseThread::getExecutingTask() { bool BaseThread::getDeleteSelfOnExecutionDone() { bool retval = false; - MutexSafeWrapper safeMutex(&mutexDeleteSelfOnExecutionDone); + MutexSafeWrapper safeMutex(&mutexDeleteSelfOnExecutionDone,string(__FILE__) + "_" + intToStr(__LINE__)); retval = deleteSelfOnExecutionDone; safeMutex.ReleaseLock(); @@ -167,7 +168,7 @@ bool BaseThread::getDeleteSelfOnExecutionDone() { } void BaseThread::setDeleteSelfOnExecutionDone(bool value) { - MutexSafeWrapper safeMutex(&mutexDeleteSelfOnExecutionDone); + MutexSafeWrapper safeMutex(&mutexDeleteSelfOnExecutionDone,string(__FILE__) + "_" + intToStr(__LINE__)); deleteSelfOnExecutionDone = value; } diff --git a/source/shared_lib/sources/platform/common/simple_threads.cpp b/source/shared_lib/sources/platform/common/simple_threads.cpp index dd704eb6c..13faae803 100644 --- a/source/shared_lib/sources/platform/common/simple_threads.cpp +++ b/source/shared_lib/sources/platform/common/simple_threads.cpp @@ -14,6 +14,7 @@ #include "util.h" #include "platform_common.h" #include +#include "conversion.h" #include "leak_dumper.h" using namespace std; @@ -86,13 +87,13 @@ SimpleTaskThread::SimpleTaskThread( SimpleTaskCallbackInterface *simpleTaskInter this->needTaskSignal = needTaskSignal; setTaskSignalled(false); - MutexSafeWrapper safeMutex(&mutexLastExecuteTimestamp); + MutexSafeWrapper safeMutex(&mutexLastExecuteTimestamp,string(__FILE__) + "_" + intToStr(__LINE__)); lastExecuteTimestamp = time(NULL); } bool SimpleTaskThread::isThreadExecutionLagging() { bool result = false; - MutexSafeWrapper safeMutex(&mutexLastExecuteTimestamp); + MutexSafeWrapper safeMutex(&mutexLastExecuteTimestamp,string(__FILE__) + "_" + intToStr(__LINE__)); result = (difftime(time(NULL),lastExecuteTimestamp) >= 5.0); safeMutex.ReleaseLock(); @@ -139,7 +140,7 @@ void SimpleTaskThread::execute() { ExecutingTaskSafeWrapper safeExecutingTaskMutex(this); this->simpleTaskInterface->simpleTask(this); - MutexSafeWrapper safeMutex(&mutexLastExecuteTimestamp); + MutexSafeWrapper safeMutex(&mutexLastExecuteTimestamp,string(__FILE__) + "_" + intToStr(__LINE__)); lastExecuteTimestamp = time(NULL); safeMutex.ReleaseLock(); } @@ -179,7 +180,7 @@ void SimpleTaskThread::execute() { void SimpleTaskThread::setTaskSignalled(bool value) { //SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); - MutexSafeWrapper safeMutex(&mutexTaskSignaller); + MutexSafeWrapper safeMutex(&mutexTaskSignaller,string(__FILE__) + "_" + intToStr(__LINE__)); taskSignalled = value; safeMutex.ReleaseLock(); @@ -190,7 +191,7 @@ bool SimpleTaskThread::getTaskSignalled() { //SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); bool retval = false; - MutexSafeWrapper safeMutex(&mutexTaskSignaller); + MutexSafeWrapper safeMutex(&mutexTaskSignaller,string(__FILE__) + "_" + intToStr(__LINE__)); retval = taskSignalled; safeMutex.ReleaseLock(); @@ -207,7 +208,7 @@ LogFileThread::LogFileThread() : BaseThread() { } void LogFileThread::addLogEntry(SystemFlags::DebugType type, string logEntry) { - MutexSafeWrapper safeMutex(&mutexLogList); + MutexSafeWrapper safeMutex(&mutexLogList,string(__FILE__) + "_" + intToStr(__LINE__)); LogFileEntry entry; entry.type = type; entry.entry = logEntry; @@ -273,14 +274,14 @@ void LogFileThread::execute() { } std::size_t LogFileThread::getLogEntryBufferCount() { - MutexSafeWrapper safeMutex(&mutexLogList); + MutexSafeWrapper safeMutex(&mutexLogList,string(__FILE__) + "_" + intToStr(__LINE__)); std::size_t logCount = logList.size(); safeMutex.ReleaseLock(); return logCount; } void LogFileThread::saveToDisk(bool forceSaveAll,bool logListAlreadyLocked) { - MutexSafeWrapper safeMutex(NULL); + MutexSafeWrapper safeMutex(NULL,string(__FILE__) + "_" + intToStr(__LINE__)); if(logListAlreadyLocked == false) { safeMutex.setMutex(&mutexLogList); } diff --git a/source/shared_lib/sources/platform/posix/ircclient.cpp b/source/shared_lib/sources/platform/posix/ircclient.cpp index b863a1afa..06ec2c56b 100644 --- a/source/shared_lib/sources/platform/posix/ircclient.cpp +++ b/source/shared_lib/sources/platform/posix/ircclient.cpp @@ -19,6 +19,7 @@ #include #include #include +#include "conversion.h" using namespace Shared::Util; using namespace Shared::PlatformCommon; @@ -101,7 +102,7 @@ void event_join(irc_session_t * session, const char * event, const char * origin bool foundNick = false; - MutexSafeWrapper safeMutex(ctx->getMutexNickList()); + MutexSafeWrapper safeMutex(ctx->getMutexNickList(),string(__FILE__) + "_" + intToStr(__LINE__)); std::vector nickList = ctx->getCachedNickList(); for(unsigned int i = 0; i < nickList.size(); ++i) { @@ -202,7 +203,7 @@ void event_channel(irc_session_t * session, const char * event, const char * ori IRCThread *ctx = (IRCThread *)irc_get_ctx(session); if(ctx != NULL) { - MutexSafeWrapper safeMutex(ctx->getMutexIRCCB()); + MutexSafeWrapper safeMutex(ctx->getMutexIRCCB(),string(__FILE__) + "_" + intToStr(__LINE__)); IRCCallbackInterface *cb = ctx->getCallbackObj(false); if(cb != NULL) { cb->IRC_CallbackEvent(IRC_evt_chatText, realNick, params, count); @@ -282,7 +283,7 @@ void event_leave(irc_session_t *session, const char *event, const char *origin, IRCThread *ctx = (IRCThread *)irc_get_ctx(session); if(ctx != NULL) { - MutexSafeWrapper safeMutex(ctx->getMutexNickList()); + MutexSafeWrapper safeMutex(ctx->getMutexNickList(),string(__FILE__) + "_" + intToStr(__LINE__)); std::vector &nickList = ctx->getCachedNickList(); for(unsigned int i = 0; i < nickList.size(); ++i) { @@ -334,7 +335,7 @@ void event_numeric(irc_session_t * session, unsigned int event, const char * ori IRCThread *ctx = (IRCThread *)irc_get_ctx(session); if(ctx != NULL) { - MutexSafeWrapper safeMutex(ctx->getMutexNickList()); + MutexSafeWrapper safeMutex(ctx->getMutexNickList(),string(__FILE__) + "_" + intToStr(__LINE__)); ctx->setCachedNickList(nickList); } } @@ -407,7 +408,7 @@ std::vector IRCThread::GetIRCConnectedNickList(string target, bool waitF } } - MutexSafeWrapper safeMutex(&mutexNickList); + MutexSafeWrapper safeMutex(&mutexNickList,string(__FILE__) + "_" + intToStr(__LINE__)); std::vector nickList = eventData; safeMutex.ReleaseLock(); @@ -424,7 +425,7 @@ bool IRCThread::isConnected() { } std::vector IRCThread::getNickList() { - MutexSafeWrapper safeMutex(&mutexNickList); + MutexSafeWrapper safeMutex(&mutexNickList,string(__FILE__) + "_" + intToStr(__LINE__)); std::vector nickList = eventData; safeMutex.ReleaseLock(); @@ -432,14 +433,14 @@ std::vector IRCThread::getNickList() { } IRCCallbackInterface * IRCThread::getCallbackObj(bool lockObj) { - MutexSafeWrapper safeMutex(NULL); + MutexSafeWrapper safeMutex(NULL,string(__FILE__) + "_" + intToStr(__LINE__)); if(lockObj == true) { safeMutex.setMutex(&mutexIRCCB); } return callbackObj; } void IRCThread::setCallbackObj(IRCCallbackInterface *cb) { - MutexSafeWrapper safeMutex(&mutexIRCCB); + MutexSafeWrapper safeMutex(&mutexIRCCB,string(__FILE__) + "_" + intToStr(__LINE__)); callbackObj=cb; } @@ -541,7 +542,7 @@ void IRCThread::execute() { // Delete ourself when the thread is done (no other actions can happen after this // such as the mutex which modifies the running status of this method - MutexSafeWrapper safeMutex(&mutexIRCCB); + MutexSafeWrapper safeMutex(&mutexIRCCB,string(__FILE__) + "_" + intToStr(__LINE__)); IRCCallbackInterface *cb = getCallbackObj(false); if(cb != NULL) { cb->IRC_CallbackEvent(IRC_evt_exitThread, NULL, NULL, 0); diff --git a/source/shared_lib/sources/platform/posix/miniftpclient.cpp b/source/shared_lib/sources/platform/posix/miniftpclient.cpp index db354954c..f1ffb8365 100644 --- a/source/shared_lib/sources/platform/posix/miniftpclient.cpp +++ b/source/shared_lib/sources/platform/posix/miniftpclient.cpp @@ -18,6 +18,7 @@ #include #include #include +#include "conversion.h" using namespace Shared::Util; using namespace Shared::PlatformCommon; @@ -185,7 +186,7 @@ int file_progress(struct FtpFile *out,double download_total, double download_now stats.upload_now = upload_now; stats.currentFilename = out->currentFilename; - MutexSafeWrapper safeMutex(out->ftpServer->getProgressMutex()); + MutexSafeWrapper safeMutex(out->ftpServer->getProgressMutex(),string(__FILE__) + "_" + intToStr(__LINE__)); out->ftpServer->getCallBackObject()->FTPClient_CallbackEvent(out->itemName, ftp_cct_DownloadProgress, ftp_crt_SUCCESS, &stats); } @@ -309,21 +310,21 @@ void FTPClientThread::getMapFromServer(string mapFileName) { } } - MutexSafeWrapper safeMutex(this->getProgressMutex()); + MutexSafeWrapper safeMutex(this->getProgressMutex(),string(__FILE__) + "_" + intToStr(__LINE__)); if(this->pCBObject != NULL) { this->pCBObject->FTPClient_CallbackEvent(mapFileName,ftp_cct_Map,result,NULL); } } void FTPClientThread::addMapToRequests(string mapFilename) { - MutexSafeWrapper safeMutex(&mutexMapFileList); + MutexSafeWrapper safeMutex(&mutexMapFileList,string(__FILE__) + "_" + intToStr(__LINE__)); if(std::find(mapFileList.begin(),mapFileList.end(),mapFilename) == mapFileList.end()) { mapFileList.push_back(mapFilename); } } void FTPClientThread::addTilesetToRequests(string tileSetName) { - MutexSafeWrapper safeMutex(&mutexTilesetList); + MutexSafeWrapper safeMutex(&mutexTilesetList,string(__FILE__) + "_" + intToStr(__LINE__)); if(std::find(tilesetList.begin(),tilesetList.end(),tileSetName) == tilesetList.end()) { tilesetList.push_back(tileSetName); } @@ -335,7 +336,7 @@ void FTPClientThread::getTilesetFromServer(string tileSetName) { result = getTilesetFromServer(tileSetName, "", FTP_TILESETS_USERNAME, FTP_COMMON_PASSWORD); } - MutexSafeWrapper safeMutex(this->getProgressMutex()); + MutexSafeWrapper safeMutex(this->getProgressMutex(),string(__FILE__) + "_" + intToStr(__LINE__)); if(this->pCBObject != NULL) { this->pCBObject->FTPClient_CallbackEvent(tileSetName,ftp_cct_Tileset,result,NULL); } @@ -492,12 +493,12 @@ FTP_Client_ResultType FTPClientThread::getTilesetFromServer(string tileSetName, } FTPClientCallbackInterface * FTPClientThread::getCallBackObject() { - MutexSafeWrapper safeMutex(this->getProgressMutex()); + MutexSafeWrapper safeMutex(this->getProgressMutex(),string(__FILE__) + "_" + intToStr(__LINE__)); return pCBObject; } void FTPClientThread::setCallBackObject(FTPClientCallbackInterface *value) { - MutexSafeWrapper safeMutex(this->getProgressMutex()); + MutexSafeWrapper safeMutex(this->getProgressMutex(),string(__FILE__) + "_" + intToStr(__LINE__)); pCBObject = value; } @@ -515,7 +516,7 @@ void FTPClientThread::execute() { try { while(this->getQuitStatus() == false) { - MutexSafeWrapper safeMutex(&mutexMapFileList); + MutexSafeWrapper safeMutex(&mutexMapFileList,string(__FILE__) + "_" + intToStr(__LINE__)); if(mapFileList.size() > 0) { string mapFilename = mapFileList[0]; mapFileList.erase(mapFileList.begin() + 0); @@ -531,7 +532,7 @@ void FTPClientThread::execute() { break; } - MutexSafeWrapper safeMutex2(&mutexTilesetList); + MutexSafeWrapper safeMutex2(&mutexTilesetList,string(__FILE__) + "_" + intToStr(__LINE__)); if(tilesetList.size() > 0) { string tileset = tilesetList[0]; tilesetList.erase(tilesetList.begin() + 0); diff --git a/source/shared_lib/sources/platform/posix/socket.cpp b/source/shared_lib/sources/platform/posix/socket.cpp index 502cb1b08..7f1ad5a3d 100644 --- a/source/shared_lib/sources/platform/posix/socket.cpp +++ b/source/shared_lib/sources/platform/posix/socket.cpp @@ -811,7 +811,7 @@ void Socket::simpleTask(BaseThread *callingThread) { for(std::map::iterator iterMap = pingCache.begin(); iterMap != pingCache.end(); iterMap++) { - MutexSafeWrapper safeMutex(&pingThreadAccessor); + MutexSafeWrapper safeMutex(&pingThreadAccessor,string(__FILE__) + "_" + intToStr(__LINE__)); iterMap->second = getAveragePingMS(iterMap->first, 1); safeMutex.ReleaseLock(); } @@ -835,7 +835,7 @@ void Socket::disconnectSocket() { if(isSocketValid() == true) { SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] calling shutdown and close for socket = %d...\n",__FILE__,__FUNCTION__,sock); - MutexSafeWrapper safeMutex(&dataSynchAccessor); + MutexSafeWrapper safeMutex(&dataSynchAccessor,string(__FILE__) + "_" + intToStr(__LINE__)); ::shutdown(sock,2); #ifndef WIN32 ::close(sock); @@ -1032,7 +1032,7 @@ int Socket::send(const void *data, int dataSize) { //SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); errno = 0; - MutexSafeWrapper safeMutex(&dataSynchAccessor); + MutexSafeWrapper safeMutex(&dataSynchAccessor,string(__FILE__) + "_" + intToStr(__LINE__)); //SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); #ifdef __APPLE__ @@ -1066,7 +1066,7 @@ int Socket::send(const void *data, int dataSize) { if(isConnected() == true) { SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] attemptCount = %d, sock = %d, dataSize = %d, data = %p\n",__FILE__,__FUNCTION__,__LINE__,attemptCount,sock,dataSize,data); - MutexSafeWrapper safeMutex(&dataSynchAccessor); + MutexSafeWrapper safeMutex(&dataSynchAccessor,string(__FILE__) + "_" + intToStr(__LINE__)); #ifdef __APPLE__ bytesSent = ::send(sock, (const char *)data, dataSize, SO_NOSIGPIPE); #else @@ -1106,7 +1106,7 @@ int Socket::send(const void *data, int dataSize) { if(isConnected() == true) { SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] attemptCount = %d, sock = %d, dataSize = %d, data = %p\n",__FILE__,__FUNCTION__,__LINE__,attemptCount,sock,dataSize,data); - MutexSafeWrapper safeMutex(&dataSynchAccessor); + MutexSafeWrapper safeMutex(&dataSynchAccessor,string(__FILE__) + "_" + intToStr(__LINE__)); const char *sendBuf = (const char *)data; #ifdef __APPLE__ bytesSent = ::send(sock, &sendBuf[totalBytesSent], dataSize - totalBytesSent, SO_NOSIGPIPE); @@ -1163,7 +1163,7 @@ int Socket::receive(void *data, int dataSize) { ssize_t bytesReceived = 0; if(isSocketValid() == true) { - MutexSafeWrapper safeMutex(&dataSynchAccessor); + MutexSafeWrapper safeMutex(&dataSynchAccessor,string(__FILE__) + "_" + intToStr(__LINE__)); bytesReceived = recv(sock, reinterpret_cast(data), dataSize, 0); } if(bytesReceived < 0 && getLastSocketError() != PLATFORM_SOCKET_TRY_AGAIN) { @@ -1184,7 +1184,7 @@ int Socket::receive(void *data, int dataSize) { break; } else if(Socket::isReadable() == true) { - MutexSafeWrapper safeMutex(&dataSynchAccessor); + MutexSafeWrapper safeMutex(&dataSynchAccessor,string(__FILE__) + "_" + intToStr(__LINE__)); bytesReceived = recv(sock, reinterpret_cast(data), dataSize, 0); SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] #2 EAGAIN during receive, trying again returned: %d\n",__FILE__,__FUNCTION__,__LINE__,bytesReceived); @@ -1207,7 +1207,7 @@ int Socket::peek(void *data, int dataSize) { ssize_t err = 0; if(isSocketValid() == true) { - MutexSafeWrapper safeMutex(&dataSynchAccessor); + MutexSafeWrapper safeMutex(&dataSynchAccessor,string(__FILE__) + "_" + intToStr(__LINE__)); err = recv(sock, reinterpret_cast(data), dataSize, MSG_PEEK); } if(err < 0 && getLastSocketError() != PLATFORM_SOCKET_TRY_AGAIN) { @@ -1230,7 +1230,7 @@ int Socket::peek(void *data, int dataSize) { break; } else if(Socket::isReadable() == true) { - MutexSafeWrapper safeMutex(&dataSynchAccessor); + MutexSafeWrapper safeMutex(&dataSynchAccessor,string(__FILE__) + "_" + intToStr(__LINE__)); err = recv(sock, reinterpret_cast(data), dataSize, MSG_PEEK); SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] #2 EAGAIN during peek, trying again returned: %d\n",__FILE__,__FUNCTION__,__LINE__,err); @@ -1285,7 +1285,7 @@ bool Socket::isReadable() { int i = 0; { - MutexSafeWrapper safeMutex(&dataSynchAccessor); + MutexSafeWrapper safeMutex(&dataSynchAccessor,string(__FILE__) + "_" + intToStr(__LINE__)); i= select((int)sock + 1, &set, NULL, NULL, &tv); } if(i < 0) { @@ -1323,7 +1323,7 @@ bool Socket::isWritable(bool waitOnDelayedResponse) { int i = 0; { - MutexSafeWrapper safeMutex(&dataSynchAccessor); + MutexSafeWrapper safeMutex(&dataSynchAccessor,string(__FILE__) + "_" + intToStr(__LINE__)); i = select((int)sock + 1, NULL, &set, NULL, &tv); } if(i < 0 ) { @@ -1506,7 +1506,7 @@ void ClientSocket::connect(const Ip &ip, int port) FD_SET(sock, &myset); { - MutexSafeWrapper safeMutex(&dataSynchAccessor); + MutexSafeWrapper safeMutex(&dataSynchAccessor,string(__FILE__) + "_" + intToStr(__LINE__)); err = select((int)sock + 1, NULL, &myset, NULL, &tv); } @@ -1887,7 +1887,7 @@ Socket *ServerSocket::accept() { struct sockaddr_in cli_addr; socklen_t clilen = sizeof(cli_addr); char client_host[100]=""; - MutexSafeWrapper safeMutex(&dataSynchAccessor); + MutexSafeWrapper safeMutex(&dataSynchAccessor,string(__FILE__) + "_" + intToStr(__LINE__)); PLATFORM_SOCKET newSock= ::accept(sock, (struct sockaddr *) &cli_addr, &clilen); safeMutex.ReleaseLock(); diff --git a/source/shared_lib/sources/util/util.cpp b/source/shared_lib/sources/util/util.cpp index 680a6d5b5..dd14f0cd4 100644 --- a/source/shared_lib/sources/util/util.cpp +++ b/source/shared_lib/sources/util/util.cpp @@ -441,7 +441,7 @@ void SystemFlags::logDebugEntry(DebugType type, string debugEntry, time_t debugT } if(currentDebugLog.fileStream->is_open() == true) { - MutexSafeWrapper safeMutex(currentDebugLog.mutex); + MutexSafeWrapper safeMutex(currentDebugLog.mutex,string(__FILE__) + "_" + intToStr(__LINE__)); (*currentDebugLog.fileStream) << "Starting Mega-Glest logging for type: " << type << "\n"; (*currentDebugLog.fileStream).flush(); @@ -453,7 +453,7 @@ void SystemFlags::logDebugEntry(DebugType type, string debugEntry, time_t debugT assert(currentDebugLog.fileStream != NULL); if(currentDebugLog.fileStream->is_open() == true) { - MutexSafeWrapper safeMutex(currentDebugLog.mutex); + MutexSafeWrapper safeMutex(currentDebugLog.mutex,string(__FILE__) + "_" + intToStr(__LINE__)); // All items in the if clause we don't want timestamps if (type != debugPathFinder && type != debugError && type != debugWorldSynch) {