diff --git a/source/glest_game/network/connection_slot.cpp b/source/glest_game/network/connection_slot.cpp index fd6a8fe6d..3a05087e7 100644 --- a/source/glest_game/network/connection_slot.cpp +++ b/source/glest_game/network/connection_slot.cpp @@ -806,10 +806,15 @@ void ConnectionSlot::close() { if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); + static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__); + MutexSafeWrapper safeMutex(&mutexCloseConnection,mutexOwnerId); + bool updateServerListener = (socket != NULL); delete socket; socket= NULL; + safeMutex.ReleaseLock(); + if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s LINE: %d]\n",__FILE__,__FUNCTION__,__LINE__); if(updateServerListener == true && ready == false) { diff --git a/source/glest_game/network/connection_slot.h b/source/glest_game/network/connection_slot.h index 96abc2ca2..ef520af9b 100644 --- a/source/glest_game/network/connection_slot.h +++ b/source/glest_game/network/connection_slot.h @@ -112,6 +112,8 @@ private: time_t connectedTime; bool gotIntro; + Mutex mutexCloseConnection; + Mutex mutexPendingNetworkCommandList; vector vctPendingNetworkCommandList; ConnectionSlotThread* slotThreadWorker;