From 4d4882d667c2c2eea180219e0c76d15cc1f49415 Mon Sep 17 00:00:00 2001 From: brain Date: Thu, 21 Feb 2008 17:27:55 +0000 Subject: Working thread test!!! git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@8983 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/threadengines/threadengine_pthread.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/threadengines') 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; } } -- cgit v1.2.3