- attempt to fix irc thread cleanup

This commit is contained in:
SoftCoder
2016-01-18 12:20:57 -08:00
parent 1125a2b405
commit d82aaa22ad

View File

@@ -736,12 +736,15 @@ void IRCThread::execute() {
{ {
RunningStatusSafeWrapper runningStatus(this); RunningStatusSafeWrapper runningStatus(this);
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] argv.size() = %d\n",__FILE__,__FUNCTION__,__LINE__,argv.size()); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] argv.size() = %d\n",__FILE__,__FUNCTION__,__LINE__,argv.size());
if(SystemFlags::VERBOSE_MODE_ENABLED || IRCThread::debugEnabled) printf ("===> IRC: IRCThread::execute Line: %d\n", __LINE__);
if(getQuitStatus() == true) { if(getQuitStatus() == true) {
if(SystemFlags::VERBOSE_MODE_ENABLED || IRCThread::debugEnabled) printf ("===> IRC: Line: %d\n", __LINE__);
return; return;
} }
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"IRC thread is running\n"); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"IRC thread is running\n");
if(SystemFlags::VERBOSE_MODE_ENABLED || IRCThread::debugEnabled) printf ("===> IRC: Line: %d\n", __LINE__);
try { try {
#if !defined(DISABLE_IRCCLIENT) #if !defined(DISABLE_IRCCLIENT)
@@ -780,6 +783,7 @@ void IRCThread::execute() {
callbacks.event_dcc_send_req = irc_event_dcc_send; callbacks.event_dcc_send_req = irc_event_dcc_send;
if(this->getQuitStatus() == true) { if(this->getQuitStatus() == true) {
if(SystemFlags::VERBOSE_MODE_ENABLED || IRCThread::debugEnabled) printf ("===> IRC: Line: %d\n", __LINE__);
return; return;
} }
safeMutex.Lock(); safeMutex.Lock();
@@ -817,6 +821,8 @@ void IRCThread::execute() {
return; return;
} }
if(SystemFlags::VERBOSE_MODE_ENABLED || IRCThread::debugEnabled) printf ("===> IRC: Line: %d\n", __LINE__);
safeMutex.Lock(); safeMutex.Lock();
if(irc_connect(ircSession, argv[0].c_str(), IRC_SERVER_PORT, 0, this->nick.c_str(), this->username.c_str(), "megaglest")) { if(irc_connect(ircSession, argv[0].c_str(), IRC_SERVER_PORT, 0, this->nick.c_str(), this->username.c_str(), "megaglest")) {
safeMutex.ReleaseLock(); safeMutex.ReleaseLock();
@@ -825,6 +831,8 @@ void IRCThread::execute() {
} }
safeMutex.ReleaseLock(); safeMutex.ReleaseLock();
if(SystemFlags::VERBOSE_MODE_ENABLED || IRCThread::debugEnabled) printf ("===> IRC: Line: %d\n", __LINE__);
if(this->getQuitStatus() == true) { if(this->getQuitStatus() == true) {
return; return;
} }
@@ -834,6 +842,7 @@ void IRCThread::execute() {
} }
//printf("In ~IRCThread Line: %d [%p]\n",__LINE__,this); //printf("In ~IRCThread Line: %d [%p]\n",__LINE__,this);
if(SystemFlags::VERBOSE_MODE_ENABLED || IRCThread::debugEnabled) printf ("===> IRC: Line: %d\n", __LINE__);
for(int iAttempts=1; for(int iAttempts=1;
this->getQuitStatus() == false && iAttempts <= 7; ++iAttempts) { this->getQuitStatus() == false && iAttempts <= 7; ++iAttempts) {
@@ -848,6 +857,8 @@ void IRCThread::execute() {
} }
} }
if(SystemFlags::VERBOSE_MODE_ENABLED || IRCThread::debugEnabled) printf ("===> IRC: Line: %d\n", __LINE__);
//printf("In ~IRCThread Line: %d [%p]\n",__LINE__,this); //printf("In ~IRCThread Line: %d [%p]\n",__LINE__,this);
#else #else
for(;this->getQuitStatus() == false;) { for(;this->getQuitStatus() == false;) {
@@ -867,20 +878,23 @@ void IRCThread::execute() {
} }
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] IRC thread is exiting\n",__FILE__,__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] IRC thread is exiting\n",__FILE__,__FUNCTION__,__LINE__);
if(SystemFlags::VERBOSE_MODE_ENABLED || IRCThread::debugEnabled) printf ("===> IRC: Line: %d\n", __LINE__);
//printf("In ~IRCThread Line: %d [%p]\n",__LINE__,this); //printf("In ~IRCThread Line: %d [%p]\n",__LINE__,this);
}
//printf("In ~IRCThread Line: %d [%p]\n",__LINE__,this);
// Delete ourself when the thread is done (no other actions can happen after this
// such as the mutex which modifies the running status of this method
MutexSafeWrapper safeMutex(&mutexIRCCB,string(__FILE__) + "_" + intToStr(__LINE__));
IRCCallbackInterface *cb = getCallbackObj(false);
if(cb != NULL) {
//printf("In ~IRCThread Line: %d [%p]\n",__LINE__,this); //printf("In ~IRCThread Line: %d [%p]\n",__LINE__,this);
cb->IRC_CallbackEvent(IRC_evt_exitThread, NULL, NULL, 0); // Delete ourself when the thread is done (no other actions can happen after this
} // such as the mutex which modifies the running status of this method
safeMutex.ReleaseLock(); MutexSafeWrapper safeMutex(&mutexIRCCB,string(__FILE__) + "_" + intToStr(__LINE__));
IRCCallbackInterface *cb = getCallbackObj(false);
if(cb != NULL) {
//printf("In ~IRCThread Line: %d [%p]\n",__LINE__,this);
if(SystemFlags::VERBOSE_MODE_ENABLED || IRCThread::debugEnabled) printf ("===> IRC: Line: %d\n", __LINE__);
cb->IRC_CallbackEvent(IRC_evt_exitThread, NULL, NULL, 0);
}
safeMutex.ReleaseLock();
}
//printf("In ~IRCThread Line: %d [%p]\n",__LINE__,this); //printf("In ~IRCThread Line: %d [%p]\n",__LINE__,this);
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In IRCThread() calling delete ...\n"); if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In IRCThread() calling delete ...\n");