- applied some memory leak cleanups

This commit is contained in:
Mark Vejvoda
2011-09-27 20:35:45 +00:00
parent 04b40ab476
commit fe8e76efd8
4 changed files with 45 additions and 9 deletions

View File

@@ -113,10 +113,20 @@ void cleanupCRCThread() {
difftime(time(NULL),elapsed) <= 45;) {
//sleep(150);
}
if(preCacheThread->canShutdown(true)) {
if(preCacheThread->canShutdown(false)) {
if(preCacheThread->shutdownAndWait() == true) {
delete preCacheThread;
}
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
}
else {
if(preCacheThread->shutdownAndWait() == true) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
delete preCacheThread;
//printf("Stopping broadcast thread [%p] - C\n",broadCastThread);
}
}
preCacheThread = NULL;
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
}

View File

@@ -66,6 +66,9 @@ MainMenu::~MainMenu() {
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
delete state;
state = NULL;
delete oldstate;
oldstate = NULL;
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);

View File

@@ -1868,23 +1868,38 @@ ServerSocket::~ServerSocket() {
UPNP_Tools::enabledUPNP = false;
}
if(urls.controlURL && urls.ipcondescURL && urls.controlURL_CIF) {
FreeUPNPUrls(&urls);
}
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
}
void ServerSocket::stopBroadCastThread() {
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
//printf("Stopping broadcast thread [%p]\n",broadCastThread);
if(broadCastThread != NULL) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
if(broadCastThread->canShutdown(true) == true) {
//printf("Stopping broadcast thread [%p] - A\n",broadCastThread);
if(broadCastThread->canShutdown(false) == true) {
sleep(0);
}
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
//printf("Stopping broadcast thread [%p] - B\n",broadCastThread);
if(broadCastThread->shutdownAndWait() == true) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
delete broadCastThread;
}
//printf("Stopping broadcast thread [%p] - C\n",broadCastThread);
}
broadCastThread = NULL;
//printf("Stopping broadcast thread [%p] - D\n",broadCastThread);
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
}
@@ -1897,6 +1912,9 @@ void ServerSocket::startBroadCastThread() {
stopBroadCastThread();
broadCastThread = new BroadCastSocketThread();
//printf("Start broadcast thread [%p]\n",broadCastThread);
broadCastThread->setUniqueID(string(__FILE__) + string("_") + string(__FUNCTION__));
broadCastThread->start();
@@ -2286,10 +2304,12 @@ void UPNP_Tools::NETremRedirects(int ext_port) {
//
BroadCastSocketThread::BroadCastSocketThread() : BaseThread() {
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
//printf("new broadcast thread [%p]\n",this);
}
BroadCastSocketThread::~BroadCastSocketThread() {
//printf("delete broadcast thread [%p]\n",this);
}
bool BroadCastSocketThread::canShutdown(bool deleteSelfIfShutdownDelayed) {

View File

@@ -320,7 +320,10 @@ void SystemFlags::Close() {
//sleep(150);
}
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
if(threadLogger->canShutdown(true)) {
// if(threadLogger->canShutdown(false)) {
// Sleep(0);
// }
if(threadLogger->shutdownAndWait() == true) {
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
delete threadLogger;
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);