summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAdam <Adam@drink-coca-cola.info>2010-05-09 17:50:53 -0400
committerAdam <Adam@anope.org>2010-06-18 21:00:04 -0400
commit4149afd45d2c0b9f464d1b4434f7bdaa61873d44 (patch)
tree7ecbfa99c159f9bbfc89d1ec36d1f84f166dd96a /src
parent6db15e17834163975f6122d3913d260d8327d516 (diff)
Changed threadengine to delete threads after Joining them, so the whole thread exists when being joined and so its safe to call non-threadsafe functions in the destructor
Diffstat (limited to 'src')
-rw-r--r--src/threadengine.cpp1
-rw-r--r--src/threadengine_pthread.cpp3
-rw-r--r--src/threadengine_win32.cpp1
3 files changed, 3 insertions, 2 deletions
diff --git a/src/threadengine.cpp b/src/threadengine.cpp
index f7e924fb6..ea652e1f2 100644
--- a/src/threadengine.cpp
+++ b/src/threadengine.cpp
@@ -12,7 +12,6 @@ Thread::Thread() : Exit(false)
*/
Thread::~Thread()
{
- Join();
}
/** Sets the exit state as true informing the thread we want it to shut down
diff --git a/src/threadengine_pthread.cpp b/src/threadengine_pthread.cpp
index 58b3a11ac..199bd0860 100644
--- a/src/threadengine_pthread.cpp
+++ b/src/threadengine_pthread.cpp
@@ -6,6 +6,7 @@ void Thread::Join()
{
SetExitState();
pthread_join(Handle, NULL);
+ delete this;
}
/* Threadengine attributes used by this thread engine */
@@ -18,7 +19,7 @@ static void *entry_point(void *parameter)
{
Thread *thread = static_cast<Thread *>(parameter);
thread->Run();
- return parameter;
+ pthread_exit(0);
}
/** Threadengines constructor
diff --git a/src/threadengine_win32.cpp b/src/threadengine_win32.cpp
index 602d8b809..d3c0303f5 100644
--- a/src/threadengine_win32.cpp
+++ b/src/threadengine_win32.cpp
@@ -6,6 +6,7 @@ void Thread::Join()
{
SetExitState();
WaitForSingleObject(Handle, INFINITE);
+ delete this;
}
/** Entry point for the thread