POSIX said: (Sure it is unclear)
The pthread_mutex_lock() function shall fail if:

[EDEADLK]
    The mutex type is PTHREAD_MUTEX_ERRORCHECK and the current thread already 
owns the mutex.

The pthread_mutex_trylock() function shall fail if:

[EBUSY]
    The mutex could not be acquired because it was already locked.

So we should allow pthread_mutex_trylock return EDEADLK or EBUSY
when the mutex is already owned.

Signed-off-by: Wanlong Gao <[email protected]>
---
 .../conformance/interfaces/pthread_cond_timedwait/2-7.c          | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git 
a/testcases/open_posix_testsuite/conformance/interfaces/pthread_cond_timedwait/2-7.c
 
b/testcases/open_posix_testsuite/conformance/interfaces/pthread_cond_timedwait/2-7.c
index 28c977e..720244c 100644
--- 
a/testcases/open_posix_testsuite/conformance/interfaces/pthread_cond_timedwait/2-7.c
+++ 
b/testcases/open_posix_testsuite/conformance/interfaces/pthread_cond_timedwait/2-7.c
@@ -228,7 +228,14 @@ void *tf(void *arg)
                        FAILED
                            ("[child] Thread did not owned the mutex after the 
timedwait return.");
                }
-               if (ret != EBUSY) {
+
+               if (td->type == PTHREAD_MUTEX_ERRORCHECK) {
+                       if (ret != EBUSY && ret != EDEADLK) {
+                               td->status = ret;
+                               UNRESOLVED(ret,
+                                  "[child] Mutex trylock did not return EBUSY 
or EDEADLK");
+                       }
+               } else if (ret != EBUSY) {
                        td->status = ret;
                        UNRESOLVED(ret,
                                   "[child] Mutex trylock did not return 
EBUSY");
-- 
1.8.3.2.634.g7a3187e


------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to