- attempt to fix thread crash when ending game for network play

This commit is contained in:
SoftCoder 2014-12-19 19:08:04 -08:00
parent 1a3e265d4a
commit 4dea67cff9
5 changed files with 16 additions and 7 deletions

@ -1 +1 @@
Subproject commit b1c0f0cc18cdd2311b581b44e7ae161317438c93 Subproject commit 19119ebb9c7c91d364c8d413194e476aa815000b

View File

@ -770,16 +770,19 @@ void Commander::giveNetworkCommand(NetworkCommand* networkCommand) const {
MutexSafeWrapper safeMutex(server->getSlotMutex(playerIndex),CODE_AT_LINE); MutexSafeWrapper safeMutex(server->getSlotMutex(playerIndex),CODE_AT_LINE);
ConnectionSlot *slot = server->getSlot(playerIndex,false); ConnectionSlot *slot = server->getSlot(playerIndex,false);
if(slot != NULL) { if(slot != NULL) {
safeMutex.ReleaseLock(true); safeMutex.ReleaseLock();
NetworkMessageQuit networkMessageQuit; NetworkMessageQuit networkMessageQuit;
slot->sendMessage(&networkMessageQuit); slot->sendMessage(&networkMessageQuit);
sleep(5); sleep(5);
//printf("Sending nctDisconnectNetworkPlayer\n"); //printf("Sending nctDisconnectNetworkPlayer\n");
safeMutex.Lock(); if(server != NULL) {
slot = server->getSlot(playerIndex,false); MutexSafeWrapper safeMutex2(server->getSlotMutex(playerIndex),CODE_AT_LINE);
if(slot != NULL) { slot = server->getSlot(playerIndex,false);
slot->close(); if(slot != NULL) {
safeMutex2.ReleaseLock();
slot->close();
}
} }
} }
} }

View File

@ -340,6 +340,7 @@ void Game::endGame() {
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
quitGame(); quitGame();
sleep(0);
Object::setStateCallback(NULL); Object::setStateCallback(NULL);
thisGamePtr = NULL; thisGamePtr = NULL;

View File

@ -250,6 +250,11 @@ void ConnectionSlotThread::execute() {
//bool socketHasReadData = Socket::hasDataToRead(socket->getSocketId()); //bool socketHasReadData = Socket::hasDataToRead(socket->getSocketId());
bool socketHasReadData = Socket::hasDataToReadWithWait(socketId,150000); bool socketHasReadData = Socket::hasDataToReadWithWait(socketId,150000);
if(getQuitStatus() == true) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
break;
}
ConnectionSlotEvent eventCopy; ConnectionSlotEvent eventCopy;
eventCopy.eventType = eReceiveSocketData; eventCopy.eventType = eReceiveSocketData;
eventCopy.connectionSlot = this->slotInterface->getSlot(slotIndex,true); eventCopy.connectionSlot = this->slotInterface->getSlot(slotIndex,true);

View File

@ -2637,7 +2637,7 @@ int UPNP_Tools::upnp_init(void *param) {
//if(devlist != NULL) { //if(devlist != NULL) {
// freeUPNPDevlist(devlist); // freeUPNPDevlist(devlist);
//} //}
devlist = NULL; //devlist = NULL;
return result; return result;
} }