Skip to content
Permalink
Browse files
- attempt to fix thread crash when ending game for network play
  • Loading branch information
softcoder committed Dec 20, 2014
1 parent 1a3e265 commit 4dea67cff9b33cedfef6174ab46813a4caab0378
@@ -770,16 +770,19 @@ void Commander::giveNetworkCommand(NetworkCommand* networkCommand) const {
MutexSafeWrapper safeMutex(server->getSlotMutex(playerIndex),CODE_AT_LINE);
ConnectionSlot *slot = server->getSlot(playerIndex,false);
if(slot != NULL) {
safeMutex.ReleaseLock(true);
safeMutex.ReleaseLock();
NetworkMessageQuit networkMessageQuit;
slot->sendMessage(&networkMessageQuit);
sleep(5);

//printf("Sending nctDisconnectNetworkPlayer\n");
safeMutex.Lock();
slot = server->getSlot(playerIndex,false);
if(slot != NULL) {
slot->close();
if(server != NULL) {
MutexSafeWrapper safeMutex2(server->getSlotMutex(playerIndex),CODE_AT_LINE);
slot = server->getSlot(playerIndex,false);
if(slot != NULL) {
safeMutex2.ReleaseLock();
slot->close();
}
}
}
}
@@ -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__);

quitGame();
sleep(0);

Object::setStateCallback(NULL);
thisGamePtr = NULL;
@@ -250,6 +250,11 @@ void ConnectionSlotThread::execute() {
//bool socketHasReadData = Socket::hasDataToRead(socket->getSocketId());
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;
eventCopy.eventType = eReceiveSocketData;
eventCopy.connectionSlot = this->slotInterface->getSlot(slotIndex,true);
@@ -2637,7 +2637,7 @@ int UPNP_Tools::upnp_init(void *param) {
//if(devlist != NULL) {
// freeUPNPDevlist(devlist);
//}
devlist = NULL;
//devlist = NULL;
return result;
}

0 comments on commit 4dea67c

Please sign in to comment.