|
|
|
|||||
|
return value of pthread_mutex_trylock() not check properly
I'm trying to get Ice working under FreeBSD.
It builds fine but make test fails: Code:
running mutex test... ../../../include/IceUtil/Mutex.h:323: IceUtil::ThreadSyscallException: thread syscall exception: Resource deadlock avoided failed test mutex failed This simple patch solves the problem: Code:
--- include/IceUtil/Mutex.h.orig Sun May 23 23:52:37 2004
+++ include/IceUtil/Mutex.h Sun May 23 23:54:30 2004
@@ -318,7 +318,7 @@
Mutex::tryLock() const
{
int rc = pthread_mutex_trylock(&_mutex);
- if(rc != 0 && rc != EBUSY)
+ if(rc != 0 && rc != EBUSY && rc != EDEADLK)
{
throw ThreadSyscallException(__FILE__, __LINE__, rc);
}
After patching both header files make test just works fine. |
|
|||||
|
Unfortunately gdb has troubles with the threading library and I'm unable to get a backtrace.
I put in some debug information to track the failing test down: This is around line 126 in MutexTest.cpp: Code:
Mutex::TryLock lock2(mutex); std::cerr << "this get's printed\n"; test(lock.tryAcquire() == false); std::cerr << "we never reach this\n"; Sorry again that I can't provide a backtrace but I hope this is information somewhat useful to you. |
|
||||||
|
Ok, now I strongly suspect a bug in the FreeBSD threading library you are using.
The C equivalent of the test to this point is pretty simple: Code:
pthread_mutex_init(...); pthread_mutex_lock(...); pthread_mutex_unlock(...); pthread_mutex_trylock(...); Perhaps you should submit this test to the FreeBSD folks as a bug report. Take care, - Mark |
|
||||||
|
Please ignore my previous reply. A colleague graciously pointed out that I was quite wrong. Thanks Benoit.
![]() It appears from this link that pthread_mutex_trylock on FreeBSD raises EDEADLK in some circumstances and EBUSY in others. At this point we would prefer not to mask the EDEADLK result by modifying Mutex::tryLock as you suggested, so we will modify the tests to trap IceUtil::ThreadSyscallException and check the result code. Thanks, - Mark |
|
|||||
|
Thanks for your quick replies and the inclusion of the fixes in Ice 1.4.
Unfortunately I missed that the monitor<mutex> test fails just for the same reason (because it was obscured by my Mutex.h patch). The failing code is test/IceUtil/thread/MonitorMutexTest.cpp, line 111: Code:
Monitor<Mutex>::TryLock tlock(monitor); |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Ice with C# not multi-threading properly | amrufon | Help Center | 12 | 09-15-2006 03:09 AM |
| Suggestion to add daemon check to Ice::Service | ctennis | Comments | 2 | 03-29-2006 03:27 PM |
| why return false ? | OrNot | Help Center | 2 | 01-04-2006 01:50 AM |
| Properly shutting ICE down. | litghost | Help Center | 8 | 11-25-2005 07:01 PM |
| Can Ice dynamically check and update its registry infomation when a Ice server dies? | rc_hz | Help Center | 3 | 11-15-2004 09:04 AM |