mirror of
https://github.com/glest/glest-source.git
synced 2025-08-20 23:21:19 +02:00
attempt to fix segfaults discovered during testing
This commit is contained in:
@@ -238,7 +238,7 @@ void BaseThread::setDeleteSelfOnExecutionDone(bool value) {
|
||||
void BaseThread::deleteSelfIfRequired() {
|
||||
if(getDeleteSelfOnExecutionDone() == true) {
|
||||
if(isThreadDeleted(this->ptr) == false) {
|
||||
delete this;
|
||||
this->setDeleteAfterExecute(true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@@ -495,7 +495,7 @@ void SimpleTaskThread::execute() {
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(isThreadDeleted(ptr_cpy) == false) {
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
delete this;
|
||||
this->setDeleteAfterExecute(true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -608,7 +608,7 @@ void LogFileThread::execute() {
|
||||
if(mustDeleteSelf == true) {
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] LogFile thread is deleting self\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(isThreadDeleted(ptr_cpy) == false) {
|
||||
delete this;
|
||||
this->setDeleteAfterExecute(true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@@ -855,7 +855,6 @@ void IRCThread::execute() {
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In IRCThread() calling delete ...\n");
|
||||
|
||||
//printf("In ~IRCThread Line: %d [%p]\n",__LINE__,this);
|
||||
//delete this;
|
||||
setDeleteAfterExecute(true);
|
||||
}
|
||||
|
||||
|
@@ -1214,7 +1214,6 @@ void FTPClientThread::execute() {
|
||||
|
||||
// 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
|
||||
//delete this;
|
||||
deleteSelfIfRequired();
|
||||
}
|
||||
|
||||
|
@@ -30,7 +30,7 @@ vector<Thread *> Thread::threadList;
|
||||
auto_ptr<Mutex> Mutex::mutexMutexList(new Mutex(CODE_AT_LINE));
|
||||
vector<Mutex *> Mutex::mutexList;
|
||||
|
||||
class ThreadAutoCleanup : public BaseThread
|
||||
class ThreadGarbageCollector : public BaseThread
|
||||
{
|
||||
protected:
|
||||
Mutex mutexPendingCleanupList;
|
||||
@@ -48,10 +48,10 @@ protected:
|
||||
return false;
|
||||
}
|
||||
public:
|
||||
ThreadAutoCleanup() : BaseThread() {
|
||||
ThreadGarbageCollector() : BaseThread() {
|
||||
removeThreadFromList();
|
||||
}
|
||||
virtual ~ThreadAutoCleanup() {
|
||||
virtual ~ThreadGarbageCollector() {
|
||||
//printf("In ~ThreadAutoCleanup Line: %d\n",__LINE__);
|
||||
}
|
||||
virtual void execute() {
|
||||
@@ -72,7 +72,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
static auto_ptr<ThreadAutoCleanup> cleanupThread;
|
||||
static auto_ptr<ThreadGarbageCollector> cleanupThread;
|
||||
// =====================================
|
||||
// Threads
|
||||
// =====================================
|
||||
@@ -194,7 +194,7 @@ void Thread::queueAutoCleanThread() {
|
||||
|
||||
if(cleanupThread.get() == NULL) {
|
||||
//printf("In Thread::shutdownThreads Line: %d\n",__LINE__);
|
||||
cleanupThread.reset(new ThreadAutoCleanup());
|
||||
cleanupThread.reset(new ThreadGarbageCollector());
|
||||
cleanupThread->start();
|
||||
sleep(0);
|
||||
}
|
||||
|
Reference in New Issue
Block a user