- attempt to fix client crash on disconnect

This commit is contained in:
Mark Vejvoda
2013-03-12 22:50:26 +00:00
parent 1e07d023ce
commit 3661d62c03
2 changed files with 23 additions and 3 deletions

View File

@@ -247,7 +247,7 @@ ClientInterface::~ClientInterface() {
//printf("B === Client destructor\n"); //printf("B === Client destructor\n");
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
close(); close(false);
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
delete clientSocket; delete clientSocket;
@@ -270,7 +270,14 @@ void ClientInterface::connect(const Ip &ip, int port) {
this->ip = ip; this->ip = ip;
this->port = port; this->port = port;
MutexSafeWrapper safeMutex(networkCommandListThreadAccessor,CODE_AT_LINE);
shutdownNetworkCommandListThread();
delete clientSocket; delete clientSocket;
clientSocket = NULL;
safeMutex.ReleaseLock();
clientSocket= new ClientSocket(); clientSocket= new ClientSocket();
clientSocket->setBlock(false); clientSocket->setBlock(false);
clientSocket->connect(ip, port); clientSocket->connect(ip, port);
@@ -1747,13 +1754,20 @@ void ClientInterface::quitGame(bool userManuallyQuit)
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Lined: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Lined: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
} }
void ClientInterface::close() void ClientInterface::close(bool lockMutex) {
{
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] START, clientSocket = %p\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,clientSocket); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] START, clientSocket = %p\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,clientSocket);
MutexSafeWrapper safeMutex(NULL,CODE_AT_LINE);
if(lockMutex == true) {
safeMutex.setMutex(networkCommandListThreadAccessor,CODE_AT_LINE);
}
shutdownNetworkCommandListThread();
delete clientSocket; delete clientSocket;
clientSocket= NULL; clientSocket= NULL;
safeMutex.ReleaseLock();
connectedTime = 0; connectedTime = 0;
gotIntro = false; gotIntro = false;
@@ -1764,6 +1778,10 @@ void ClientInterface::close()
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] END\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] END\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
} }
void ClientInterface::close() {
close(true);
}
void ClientInterface::discoverServers(DiscoveredServersInterface *cb) { void ClientInterface::discoverServers(DiscoveredServersInterface *cb) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);

View File

@@ -192,6 +192,8 @@ protected:
void updateFrame(int *checkFrame); void updateFrame(int *checkFrame);
void shutdownNetworkCommandListThread(); void shutdownNetworkCommandListThread();
bool getNetworkCommand(int frameCount, int currentCachedPendingCommandsIndex); bool getNetworkCommand(int frameCount, int currentCachedPendingCommandsIndex);
void close(bool lockMutex);
}; };
}}//end namespace }}//end namespace