diff options
author | Matthias Huetsch <mhu@openoffice.org> | 2001-08-23 18:21:42 +0000 |
---|---|---|
committer | Matthias Huetsch <mhu@openoffice.org> | 2001-08-23 18:21:42 +0000 |
commit | a38a5284e3e587ad938ccd799526fbc6d1808a7b (patch) | |
tree | dd5257c909d2886622d2ef4e2e58b0e608807b88 /sal | |
parent | 48143a874a0e68984f0918c7543516f793a8eef2 (diff) |
#91257# Fixed 'oslCleanupFunction()' to call 'pthread_detach()'
symmetrically to 'osl_destroyThread()'. Otherwise threads may never be
detached or joined at all, and thus leaking resources.
Diffstat (limited to 'sal')
-rw-r--r-- | sal/osl/unx/thread.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/sal/osl/unx/thread.c b/sal/osl/unx/thread.c index e514875cc287..31c59aa57746 100644 --- a/sal/osl/unx/thread.c +++ b/sal/osl/unx/thread.c @@ -2,9 +2,9 @@ * * $RCSfile: thread.c,v $ * - * $Revision: 1.20 $ + * $Revision: 1.21 $ * - * last change: $Author: jbu $ $Date: 2001-06-08 16:56:42 $ + * last change: $Author: mhu $ $Date: 2001-08-23 19:21:42 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -273,8 +273,13 @@ static void oslCleanupFunction(void* pData) pthread_mutex_lock(&pThreadImpl->m_HandleLock); pThreadImpl->m_Flags &= ~THREADIMPL_FLAGS_ACTIVE; - attached = pThreadImpl->m_Flags & THREADIMPL_FLAGS_ATTACHED; - pThreadImpl->m_Flags &= ~THREADIMPL_FLAGS_ATTACHED; + + if ((attached = pThreadImpl->m_Flags & THREADIMPL_FLAGS_ATTACHED) > 0) + { + pThreadImpl->m_Flags &= ~THREADIMPL_FLAGS_ATTACHED; + + pthread_detach(pThreadImpl->m_hThread); + } pthread_mutex_unlock(&pThreadImpl->m_HandleLock); removeThreadId(); @@ -325,7 +330,6 @@ static void* oslWorkerWrapperFunction(void* pData) while ( nRet != 0 ); } - pthread_mutex_unlock(&pThreadImpl->m_AccessLock); /* call worker-function with data */ @@ -571,6 +575,7 @@ void SAL_CALL osl_destroyThread(oslThread Thread) if ( (attached = (pThreadImpl->m_Flags & THREADIMPL_FLAGS_ATTACHED)) > 0 ) { pThreadImpl->m_Flags &= ~THREADIMPL_FLAGS_ATTACHED; + pthread_detach(pThreadImpl->m_hThread); } pthread_mutex_unlock(&pThreadImpl->m_HandleLock); |