diff options
author | Michi Henning <michi@zeroc.com> | 2002-12-02 23:59:04 +0000 |
---|---|---|
committer | Michi Henning <michi@zeroc.com> | 2002-12-02 23:59:04 +0000 |
commit | 551dbf1ea7779b35a0e775cb9500a2143622351c (patch) | |
tree | fd7c6cbddd2360077fb2504296807bfe933b6dac /cpp/src | |
parent | adding constructors (diff) | |
download | ice-551dbf1ea7779b35a0e775cb9500a2143622351c.tar.bz2 ice-551dbf1ea7779b35a0e775cb9500a2143622351c.tar.xz ice-551dbf1ea7779b35a0e775cb9500a2143622351c.zip |
Added explicit test for double detach -- pthread_detach() doesn't always
return ESRCH when a detached thread is detached again.
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/IceUtil/Thread.cpp | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/cpp/src/IceUtil/Thread.cpp b/cpp/src/IceUtil/Thread.cpp index 067bd721d76..5a7d8a33c4b 100644 --- a/cpp/src/IceUtil/Thread.cpp +++ b/cpp/src/IceUtil/Thread.cpp @@ -22,8 +22,8 @@ using namespace std; IceUtil::ThreadControl::ThreadControl() : _handle(new HandleWrapper(0)), - _detached(false), - _id(GetCurrentThreadId()) + _id(GetCurrentThreadId()), + _detached(false) { HANDLE proc = GetCurrentProcess(); HANDLE current = GetCurrentThread(); @@ -36,8 +36,8 @@ IceUtil::ThreadControl::ThreadControl() : IceUtil::ThreadControl::ThreadControl(const HandleWrapperPtr& handle, unsigned id) : _handle(handle), - _detached(false), - _id(id) + _id(id), + _detached(false) { } @@ -212,12 +212,14 @@ IceUtil::Thread::operator<(const Thread& rhs) const #else IceUtil::ThreadControl::ThreadControl(pthread_t id) : - _id(id) + _id(id), + _detached(false) { } IceUtil::ThreadControl::ThreadControl() : - _id(pthread_self()) + _id(pthread_self()), + _detached(false) { } @@ -245,6 +247,11 @@ IceUtil::ThreadControl::join() { if(_id) { + if (_detached) + { + throw ThreadSyscallException(__FILE__, __LINE__); + } + _detached = true; void* ignore = 0; int rc = pthread_join(_id, &ignore); if(rc != 0) @@ -259,6 +266,11 @@ IceUtil::ThreadControl::detach() { if(_id) { + if (_detached) + { + throw ThreadSyscallException(__FILE__, __LINE__); + } + _detached = true; int rc = pthread_detach(_id); if(rc != 0) { |