diff options
author | Dwayne Boone <dwayne@zeroc.com> | 2006-04-19 00:30:06 +0000 |
---|---|---|
committer | Dwayne Boone <dwayne@zeroc.com> | 2006-04-19 00:30:06 +0000 |
commit | 5fe818e133abbf3feee85ba8dd726c71861f2cdc (patch) | |
tree | 86ee705e94bac8a2e7ab9d7de1511b6e818b1244 /cpp | |
parent | fixing copyright (diff) | |
download | ice-5fe818e133abbf3feee85ba8dd726c71861f2cdc.tar.bz2 ice-5fe818e133abbf3feee85ba8dd726c71861f2cdc.tar.xz ice-5fe818e133abbf3feee85ba8dd726c71861f2cdc.zip |
Fix for FC5
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/include/IceUtil/Mutex.h | 9 | ||||
-rw-r--r-- | cpp/include/IceUtil/StaticMutex.h | 9 | ||||
-rw-r--r-- | cpp/test/IceUtil/thread/MonitorMutexTest.cpp | 16 | ||||
-rw-r--r-- | cpp/test/IceUtil/thread/MutexTest.cpp | 8 | ||||
-rw-r--r-- | cpp/test/IceUtil/thread/StaticMutexTest.cpp | 8 |
5 files changed, 37 insertions, 13 deletions
diff --git a/cpp/include/IceUtil/Mutex.h b/cpp/include/IceUtil/Mutex.h index 66b940e3a9b..9a33a147445 100644 --- a/cpp/include/IceUtil/Mutex.h +++ b/cpp/include/IceUtil/Mutex.h @@ -315,7 +315,14 @@ Mutex::tryLock() const int rc = pthread_mutex_trylock(&_mutex); if(rc != 0 && rc != EBUSY) { - throw ThreadSyscallException(__FILE__, __LINE__, rc); + if(rc == EDEADLOCK) + { + throw ThreadLockedException(__FILE__, __LINE__); + } + else + { + throw ThreadSyscallException(__FILE__, __LINE__, rc); + } } return (rc == 0); } diff --git a/cpp/include/IceUtil/StaticMutex.h b/cpp/include/IceUtil/StaticMutex.h index 64332a0bd53..f499f6f1674 100644 --- a/cpp/include/IceUtil/StaticMutex.h +++ b/cpp/include/IceUtil/StaticMutex.h @@ -295,7 +295,14 @@ StaticMutex::tryLock() const int rc = pthread_mutex_trylock(&_mutex); if(rc != 0 && rc != EBUSY) { - throw ThreadSyscallException(__FILE__, __LINE__, rc); + if(rc == EDEADLOCK) + { + throw ThreadLockedException(__FILE__, __LINE__); + } + else + { + throw ThreadSyscallException(__FILE__, __LINE__, rc); + } } return (rc == 0); } diff --git a/cpp/test/IceUtil/thread/MonitorMutexTest.cpp b/cpp/test/IceUtil/thread/MonitorMutexTest.cpp index 98ae8360222..e1a2dbb6d45 100644 --- a/cpp/test/IceUtil/thread/MonitorMutexTest.cpp +++ b/cpp/test/IceUtil/thread/MonitorMutexTest.cpp @@ -108,9 +108,19 @@ MonitorMutexTest::run() { Monitor<Mutex>::Lock lock(monitor); - Monitor<Mutex>::TryLock tlock(monitor); - test(!tlock.acquired()); - + try + { + Monitor<Mutex>::TryLock tlock(monitor); + test(!tlock.acquired()); + } + catch(const ThreadLockedException&) + { + // + // pthread_mutex_trylock returns EDEADLK in FreeBSD's new threading implementation + // as well as in Fedora Core 5. + // + } + // TEST: Start thread, try to acquire the mutex. t = new MonitorMutexTestThread(monitor); control = t->start(); diff --git a/cpp/test/IceUtil/thread/MutexTest.cpp b/cpp/test/IceUtil/thread/MutexTest.cpp index be0e80546af..a5bbeca5bb6 100644 --- a/cpp/test/IceUtil/thread/MutexTest.cpp +++ b/cpp/test/IceUtil/thread/MutexTest.cpp @@ -119,17 +119,17 @@ MutexTest::run() } Mutex::TryLock lock2(mutex); -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) || defined(__linux) try { test(lock.tryAcquire() == false); } - catch(const IceUtil::ThreadSyscallException& ex) + catch(const IceUtil::ThreadLockedException& ex) { // - // pthread_mutex_trylock returns EDEADLK in FreeBSD's new threading implementation. + // pthread_mutex_trylock returns EDEADLK in FreeBSD's new threading implementation + // as well as in Fedora Core 5. // - test(ex.error() == EDEADLK); } #else test(lock.tryAcquire() == false); diff --git a/cpp/test/IceUtil/thread/StaticMutexTest.cpp b/cpp/test/IceUtil/thread/StaticMutexTest.cpp index 4bf1174eb7e..a22fcb53f47 100644 --- a/cpp/test/IceUtil/thread/StaticMutexTest.cpp +++ b/cpp/test/IceUtil/thread/StaticMutexTest.cpp @@ -118,17 +118,17 @@ StaticMutexTest::run() } StaticMutex::TryLock lock2(staticMutex); -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) || defined(__linux) try { test(lock.tryAcquire() == false); } - catch(const IceUtil::ThreadSyscallException& ex) + catch(const IceUtil::ThreadLockedException& ex) { // - // pthread_mutex_trylock returns EDEADLK in FreeBSD's new threading implementation. + // pthread_mutex_trylock returns EDEADLK in FreeBSD's new threading implementation + // as well as in Fedora Core 5. // - test(ex.error() == EDEADLK); } #else test(lock.tryAcquire() == false); |