View Single Post
  #1 (permalink)  
Old 05-24-2004
stefan stefan is offline
Registered User
 
 
Join Date: May 2004
Posts: 3
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
After some investigation it turned out that in Mutex.h the return value of pthread_mutex_trylock() is tested against EBUSY. But the new threading library in FreeBSD returns EDEADLK (which seems to be okay according to the standard).

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);
     }
Exactly the same problem occurs in StaticMutex.h.

After patching both header files make test just works fine.
Reply With Quote