mirror of
https://github.com/glest/glest-source.git
synced 2025-08-17 13:50:43 +02:00
bugfix to close irc client down quickly when exiting application.
This commit is contained in:
@@ -205,37 +205,68 @@ static void cleanupProcessObjects() {
|
|||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("#2 IRCCLient Cache SHUTDOWN\n");
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("#2 IRCCLient Cache SHUTDOWN\n");
|
||||||
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__);
|
||||||
|
|
||||||
|
//printf("Closing IRC CLient %d\n",__LINE__);
|
||||||
|
ircClient->disconnect();
|
||||||
|
ircClient = NULL;
|
||||||
|
|
||||||
|
/*
|
||||||
ircClient->setCallbackObj(NULL);
|
ircClient->setCallbackObj(NULL);
|
||||||
|
|
||||||
//printf("In main IRCThreadcheck [%p] signalled quit...\n",ircClient);
|
//printf("In main IRCThreadcheck [%p] signalled quit...\n",ircClient);
|
||||||
|
printf("Closing IRC CLient %d\n",__LINE__);
|
||||||
ircClient->signalQuit();
|
ircClient->signalQuit();
|
||||||
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__);
|
||||||
|
|
||||||
|
ircClient->disconnect();
|
||||||
ircClient = NULL;
|
ircClient = NULL;
|
||||||
|
|
||||||
|
printf("Closing IRC CLient %d\n",__LINE__);
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("#3 IRCCLient Cache SHUTDOWN\n");
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("#3 IRCCLient Cache SHUTDOWN\n");
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("#4 IRCCLient Cache SHUTDOWN\n");
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("#4 IRCCLient Cache SHUTDOWN\n");
|
||||||
|
|
||||||
|
//printf("Closing IRC CLient %d\n",__LINE__);
|
||||||
|
|
||||||
cleanupCRCThread();
|
cleanupCRCThread();
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
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__);
|
||||||
|
|
||||||
|
//printf("Closing IRC CLient %d\n",__LINE__);
|
||||||
if(Renderer::isEnded() == false) {
|
if(Renderer::isEnded() == false) {
|
||||||
Renderer::getInstance().end();
|
Renderer::getInstance().end();
|
||||||
CoreData &coreData= CoreData::getInstance();
|
CoreData &coreData= CoreData::getInstance();
|
||||||
coreData.cleanup();
|
coreData.cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//printf("Closing IRC CLient %d\n",__LINE__);
|
||||||
|
|
||||||
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__);
|
||||||
|
|
||||||
SystemFlags::Close();
|
SystemFlags::Close();
|
||||||
SystemFlags::SHUTDOWN_PROGRAM_MODE=true;
|
SystemFlags::SHUTDOWN_PROGRAM_MODE=true;
|
||||||
|
|
||||||
|
//printf("Closing IRC CLient %d\n",__LINE__);
|
||||||
|
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("start running threads = " MG_SIZE_T_SPECIFIER "\n",Thread::getThreadList().size());
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("start running threads = " MG_SIZE_T_SPECIFIER "\n",Thread::getThreadList().size());
|
||||||
time_t elapsed = time(NULL);
|
time_t elapsed = time(NULL);
|
||||||
|
int lastLazyThreadDump = 0;
|
||||||
for(;Thread::getThreadList().size() > 0 &&
|
for(;Thread::getThreadList().size() > 0 &&
|
||||||
difftime((long int)time(NULL),elapsed) <= 10;) {
|
difftime((long int)time(NULL),elapsed) <= 10;) {
|
||||||
//sleep(0);
|
//sleep(0);
|
||||||
|
if(difftime((long int)time(NULL),elapsed) > 1) {
|
||||||
|
if(lastLazyThreadDump != (int)difftime((long int)time(NULL),elapsed)) {
|
||||||
|
lastLazyThreadDump = difftime((long int)time(NULL),elapsed);
|
||||||
|
|
||||||
|
std::vector<Thread *> threadList = Thread::getThreadList();
|
||||||
|
printf("Waiting for the following threads to exit [" MG_SIZE_T_SPECIFIER "]:\n",threadList.size());
|
||||||
|
|
||||||
|
for(int i = 0; i < threadList.size(); ++i) {
|
||||||
|
BaseThread *baseThread = dynamic_cast<BaseThread *>(threadList[i]);
|
||||||
|
printf("Thread index: %d isBaseThread: %d, Name: [%s]\n",i,(baseThread != NULL),baseThread->getUniqueID().c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("end running threads = " MG_SIZE_T_SPECIFIER "\n",Thread::getThreadList().size());
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("end running threads = " MG_SIZE_T_SPECIFIER "\n",Thread::getThreadList().size());
|
||||||
|
|
||||||
@@ -256,11 +287,18 @@ static void cleanupProcessObjects() {
|
|||||||
|
|
||||||
XmlIo::getInstance().cleanup();
|
XmlIo::getInstance().cleanup();
|
||||||
|
|
||||||
|
//printf("Closing IRC CLient %d\n",__LINE__);
|
||||||
|
|
||||||
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__);
|
||||||
|
|
||||||
|
|
||||||
SystemFlags::globalCleanupHTTP();
|
SystemFlags::globalCleanupHTTP();
|
||||||
|
|
||||||
|
//printf("Closing IRC CLient %d\n",__LINE__);
|
||||||
|
|
||||||
CacheManager::cleanupMutexes();
|
CacheManager::cleanupMutexes();
|
||||||
|
|
||||||
|
//printf("Closing IRC CLient %d\n",__LINE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(WIN32) && !defined(_DEBUG) && !defined(__GNUC__)
|
#if defined(WIN32) && !defined(_DEBUG) && !defined(__GNUC__)
|
||||||
@@ -5155,6 +5193,8 @@ int glestMain(int argc, char** argv) {
|
|||||||
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__);
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
|
//printf("Closing IRC CLient %d\n",__LINE__);
|
||||||
|
|
||||||
delete mainWindow;
|
delete mainWindow;
|
||||||
mainWindow = NULL;
|
mainWindow = NULL;
|
||||||
|
|
||||||
@@ -5170,6 +5210,8 @@ int glestMain(int argc, char** argv) {
|
|||||||
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__);
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
|
//printf("Closing IRC CLient %d\n",__LINE__);
|
||||||
|
|
||||||
if(soundThreadManager) {
|
if(soundThreadManager) {
|
||||||
SoundRenderer &soundRenderer= SoundRenderer::getInstance();
|
SoundRenderer &soundRenderer= SoundRenderer::getInstance();
|
||||||
if( Config::getInstance().getString("FactorySound","") != "None" &&
|
if( Config::getInstance().getString("FactorySound","") != "None" &&
|
||||||
@@ -5185,6 +5227,8 @@ int glestMain(int argc, char** argv) {
|
|||||||
soundThreadManager = NULL;
|
soundThreadManager = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//printf("Closing IRC CLient %d\n",__LINE__);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -323,9 +323,11 @@ MenuStateMasterserver::MenuStateMasterserver(Program *program, MainMenu *mainMen
|
|||||||
|
|
||||||
if(ircThread == NULL) {
|
if(ircThread == NULL) {
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("#2 IRCCLient Cache check\n");
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("#2 IRCCLient Cache check\n");
|
||||||
|
|
||||||
|
static string mutexOwnerId = string(extractFileFromDirectoryPath(__FILE__).c_str()) + string("_") + intToStr(__LINE__);
|
||||||
ircThread = new IRCThread(ircArgs,this);
|
ircThread = new IRCThread(ircArgs,this);
|
||||||
ircClient = ircThread;
|
ircClient = ircThread;
|
||||||
ircClient->setUniqueID(extractFileFromDirectoryPath(__FILE__).c_str());
|
ircClient->setUniqueID(mutexOwnerId);
|
||||||
ircClient->setPlayerName(netPlayerName);
|
ircClient->setPlayerName(netPlayerName);
|
||||||
ircClient->start();
|
ircClient->start();
|
||||||
}
|
}
|
||||||
|
@@ -128,6 +128,7 @@ public:
|
|||||||
void joinChannel();
|
void joinChannel();
|
||||||
void leaveChannel();
|
void leaveChannel();
|
||||||
void connectToHost();
|
void connectToHost();
|
||||||
|
void disconnect();
|
||||||
};
|
};
|
||||||
|
|
||||||
}}//end namespace
|
}}//end namespace
|
||||||
|
@@ -473,6 +473,22 @@ IRCThread::IRCThread(const std::vector<string> &argv, IRCCallbackInterface *call
|
|||||||
playerName = "";
|
playerName = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void IRCThread::disconnect() {
|
||||||
|
#if !defined(DISABLE_IRCCLIENT)
|
||||||
|
if(ircSession != NULL) {
|
||||||
|
setCallbackObj(NULL);
|
||||||
|
if(SystemFlags::VERBOSE_MODE_ENABLED || IRCThread::debugEnabled) printf ("===> IRC: Quitting Channel\n");
|
||||||
|
|
||||||
|
irc_disconnect(ircSession);
|
||||||
|
|
||||||
|
BaseThread::signalQuit();
|
||||||
|
hasJoinedChannel = false;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
BaseThread::signalQuit();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void IRCThread::signalQuit() {
|
void IRCThread::signalQuit() {
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED || IRCThread::debugEnabled) printf ("===> IRC: signalQuit [%p]\n",ircSession);
|
if(SystemFlags::VERBOSE_MODE_ENABLED || IRCThread::debugEnabled) printf ("===> IRC: signalQuit [%p]\n",ircSession);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user