Module: xenomai-gch
Branch: for-head
Commit: 58c1b922a96fedaef110c925a0dddb0e86dbcaf4
URL:    
http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=58c1b922a96fedaef110c925a0dddb0e86dbcaf4

Author: Gilles Chanteperdrix <gilles.chanteperd...@xenomai.org>
Date:   Thu Dec  3 21:13:54 2009 +0100

posix: cosmetic cleanup of pthread_cond_*wait

---

 src/skins/posix/cond.c |   26 +++++++++++---------------
 1 files changed, 11 insertions(+), 15 deletions(-)

diff --git a/src/skins/posix/cond.c b/src/skins/posix/cond.c
index 0582367..d7087e6 100644
--- a/src/skins/posix/cond.c
+++ b/src/skins/posix/cond.c
@@ -86,7 +86,7 @@ struct pse51_cond_cleanup_t {
        unsigned count;
 };
 
-static void __pthread_cond_cleanup(void *data)
+static void __pthread_cond_relock_mutex(void *data)
 {
        struct pse51_cond_cleanup_t *c = (struct pse51_cond_cleanup_t *) data;
        int err;
@@ -111,7 +111,7 @@ int __wrap_pthread_cond_wait(pthread_cond_t *cond, 
pthread_mutex_t *mutex)
        if (cb_try_read_lock(&c.mutex->shadow_mutex.lock, s))
                return EINVAL;
 
-       pthread_cleanup_push(&__pthread_cond_cleanup, &c);
+       pthread_cleanup_push(&__pthread_cond_relock_mutex, &c);
 
        pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldtype);
 
@@ -124,12 +124,10 @@ int __wrap_pthread_cond_wait(pthread_cond_t *cond, 
pthread_mutex_t *mutex)
 
        pthread_cleanup_pop(0);
 
-       while (err == EINTR)
-               err = -XENOMAI_SKINCALL3(__pse51_muxid,
-                                        __pse51_cond_wait_epilogue,
-                                        &c.cond->shadow_cond,
-                                        &c.mutex->shadow_mutex,
-                                        c.count);
+       if (err == EINTR) {
+               err = 0;
+               __pthread_cond_relock_mutex(&c);
+       }
 
        cb_read_unlock(&c.mutex->shadow_mutex.lock, s);
 
@@ -151,7 +149,7 @@ int __wrap_pthread_cond_timedwait(pthread_cond_t * cond,
        if (cb_try_read_lock(&c.mutex->shadow_mutex.lock, s))
                return EINVAL;
 
-       pthread_cleanup_push(&__pthread_cond_cleanup, &c);
+       pthread_cleanup_push(&__pthread_cond_relock_mutex, &c);
 
        pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldtype);
 
@@ -163,12 +161,10 @@ int __wrap_pthread_cond_timedwait(pthread_cond_t * cond,
 
        pthread_cleanup_pop(0);
 
-       while (err == EINTR)
-               err = -XENOMAI_SKINCALL3(__pse51_muxid,
-                                        __pse51_cond_wait_epilogue,
-                                        &c.cond->shadow_cond,
-                                        &c.mutex->shadow_mutex,
-                                        c.count);
+       if (err == EINTR) {
+               err = 0;
+               __pthread_cond_relock_mutex(&c);
+       }
 
        cb_read_unlock(&c.mutex->shadow_mutex.lock, s);
 


_______________________________________________
Xenomai-git mailing list
Xenomai-git@gna.org
https://mail.gna.org/listinfo/xenomai-git

Reply via email to