summaryrefslogtreecommitdiff
path: root/src/threadengines
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2008-02-21 17:27:55 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2008-02-21 17:27:55 +0000
commit4d4882d667c2c2eea180219e0c76d15cc1f49415 (patch)
tree86acc379875db7359b342812bd18b7edbe3ee60a /src/threadengines
parent4e5244a4d82ea5083c401ac04440cb8dd6003941 (diff)
Working thread test!!!
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@8983 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/threadengines')
-rw-r--r--src/threadengines/threadengine_pthread.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/threadengines/threadengine_pthread.cpp b/src/threadengines/threadengine_pthread.cpp
index da120bfab..8bdcd6d96 100644
--- a/src/threadengines/threadengine_pthread.cpp
+++ b/src/threadengines/threadengine_pthread.cpp
@@ -36,6 +36,7 @@ void PThreadEngine::Create(Thread* thread_to_init)
{
pthread_attr_t attribs;
pthread_attr_init(&attribs);
+ pthread_attr_setdetachstate(&attribs, PTHREAD_CREATE_JOINABLE);
pthread_t* MyPThread = new pthread_t;
if (pthread_create(MyPThread, &attribs, PThreadEngine::Entry, (void*)this) != 0)
@@ -44,6 +45,8 @@ void PThreadEngine::Create(Thread* thread_to_init)
throw CoreException("Unable to create new PThreadEngine: " + std::string(strerror(errno)));
}
+ pthread_attr_destroy(&attribs);
+
NewThread = thread_to_init;
NewThread->Creator = this;
NewThread->Extend("pthread", MyPThread);
@@ -81,6 +84,10 @@ void PThreadEngine::FreeThread(Thread* thread)
pthread_t* pthread = NULL;
if (thread->GetExt("pthread", pthread))
{
+ thread->SetExitFlag();
+ int rc;
+ void* status;
+ rc = pthread_join(*pthread, &status);
delete pthread;
}
}