- attempt to fix ftpclient error on shutdown shown by nig

This commit is contained in:
Mark Vejvoda 2013-01-29 00:10:27 +00:00
parent d6c5c2ac0e
commit 6acf5e9e67
2 changed files with 121 additions and 28 deletions

View File

@ -697,11 +697,30 @@ MenuStateConnectedGame::~MenuStateConnectedGame() {
}
if(ftpClientThread != NULL) {
ftpClientThread->setCallBackObject(NULL);
if(ftpClientThread->shutdownAndWait() == true) {
delete ftpClientThread;
ftpClientThread = NULL;
}
ftpClientThread->setCallBackObject(NULL);
ftpClientThread->signalQuit();
sleep(0);
if(ftpClientThread->canShutdown(true) == true &&
ftpClientThread->shutdownAndWait() == true) {
delete ftpClientThread;
}
else {
char szBuf[8096]="";
snprintf(szBuf,8096,"In [%s::%s %d] Error cannot shutdown ftpClientThread\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
//SystemFlags::OutputDebug(SystemFlags::debugError,szBuf);
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("%s",szBuf);
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s",szBuf);
//publishToMasterserverThread->cleanup();
}
ftpClientThread = NULL;
// ftpClientThread->setCallBackObject(NULL);
// if(ftpClientThread->shutdownAndWait() == true) {
// delete ftpClientThread;
// ftpClientThread = NULL;
// }
}
cleanupMapPreviewTexture();
@ -1243,10 +1262,29 @@ void MenuStateConnectedGame::mouseClick(int x, int y, MouseButton mouseButton){
}
else if(buttonCancelDownloads.mouseClick(x,y)) {
if(ftpClientThread != NULL && fileFTPProgressList.empty() == false) {
ftpClientThread->setCallBackObject(NULL);
if(ftpClientThread->shutdownAndWait() == true) {
delete ftpClientThread;
}
ftpClientThread->setCallBackObject(NULL);
ftpClientThread->signalQuit();
sleep(0);
if(ftpClientThread->canShutdown(true) == true &&
ftpClientThread->shutdownAndWait() == true) {
delete ftpClientThread;
}
else {
char szBuf[8096]="";
snprintf(szBuf,8096,"In [%s::%s %d] Error cannot shutdown ftpClientThread\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
//SystemFlags::OutputDebug(SystemFlags::debugError,szBuf);
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("%s",szBuf);
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s",szBuf);
//publishToMasterserverThread->cleanup();
}
ftpClientThread = NULL;
// ftpClientThread->setCallBackObject(NULL);
// if(ftpClientThread->shutdownAndWait() == true) {
// delete ftpClientThread;
// }
fileFTPProgressList.clear();
getMissingMapFromFTPServerInProgress = false;
@ -2142,11 +2180,30 @@ void MenuStateConnectedGame::returnToJoinMenu() {
}
if(ftpClientThread != NULL) {
ftpClientThread->setCallBackObject(NULL);
if(ftpClientThread->shutdownAndWait() == true) {
delete ftpClientThread;
ftpClientThread = NULL;
}
ftpClientThread->setCallBackObject(NULL);
ftpClientThread->signalQuit();
sleep(0);
if(ftpClientThread->canShutdown(true) == true &&
ftpClientThread->shutdownAndWait() == true) {
delete ftpClientThread;
}
else {
char szBuf[8096]="";
snprintf(szBuf,8096,"In [%s::%s %d] Error cannot shutdown ftpClientThread\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
//SystemFlags::OutputDebug(SystemFlags::debugError,szBuf);
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("%s",szBuf);
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s",szBuf);
//publishToMasterserverThread->cleanup();
}
ftpClientThread = NULL;
// ftpClientThread->setCallBackObject(NULL);
// if(ftpClientThread->shutdownAndWait() == true) {
// delete ftpClientThread;
// ftpClientThread = NULL;
// }
}
if(returnMenuInfo == jmSimple) {
@ -3089,11 +3146,29 @@ void MenuStateConnectedGame::update() {
}
if(ftpClientThread != NULL) {
ftpClientThread->setCallBackObject(NULL);
if(ftpClientThread->shutdownAndWait() == true) {
delete ftpClientThread;
ftpClientThread = NULL;
}
ftpClientThread->setCallBackObject(NULL);
ftpClientThread->signalQuit();
sleep(0);
if(ftpClientThread->canShutdown(true) == true &&
ftpClientThread->shutdownAndWait() == true) {
delete ftpClientThread;
}
else {
char szBuf[8096]="";
snprintf(szBuf,8096,"In [%s::%s %d] Error cannot shutdown ftpClientThread\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
//SystemFlags::OutputDebug(SystemFlags::debugError,szBuf);
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("%s",szBuf);
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s",szBuf);
//publishToMasterserverThread->cleanup();
}
ftpClientThread = NULL;
// ftpClientThread->setCallBackObject(NULL);
// if(ftpClientThread->shutdownAndWait() == true) {
// delete ftpClientThread;
// ftpClientThread = NULL;
// }
}
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);

View File

@ -1135,15 +1135,33 @@ void MenuStateMods::cleanUp() {
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
if(ftpClientThread != NULL) {
ftpClientThread->signalQuit();
ftpClientThread->setCallBackObject(NULL);
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
if( ftpClientThread->shutdownAndWait() == true) {
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
delete ftpClientThread;
}
ftpClientThread = NULL;
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
ftpClientThread->setCallBackObject(NULL);
ftpClientThread->signalQuit();
sleep(0);
if(ftpClientThread->canShutdown(true) == true &&
ftpClientThread->shutdownAndWait() == true) {
delete ftpClientThread;
}
else {
char szBuf[8096]="";
snprintf(szBuf,8096,"In [%s::%s %d] Error cannot shutdown ftpClientThread\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
//SystemFlags::OutputDebug(SystemFlags::debugError,szBuf);
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("%s",szBuf);
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s",szBuf);
//publishToMasterserverThread->cleanup();
}
ftpClientThread = NULL;
// ftpClientThread->signalQuit();
// ftpClientThread->setCallBackObject(NULL);
// if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
// if( ftpClientThread->shutdownAndWait() == true) {
// if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
// delete ftpClientThread;
// }
// ftpClientThread = NULL;
// if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
}
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);