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

Author: Gilles Chanteperdrix <gilles.chanteperd...@xenomai.org>
Date:   Wed Nov 25 07:16:51 2009 +0100

posix: fix pthread_cond_wait restarting

---

 ksrc/skins/posix/syscall.c |   25 +++++++++++++++++++++----
 1 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/ksrc/skins/posix/syscall.c b/ksrc/skins/posix/syscall.c
index c08db8b..ea1d695 100644
--- a/ksrc/skins/posix/syscall.c
+++ b/ksrc/skins/posix/syscall.c
@@ -1559,17 +1559,33 @@ static int __pthread_cond_wait_prologue(struct pt_regs 
*regs)
                                                    &cnd.shadow_cond,
                                                    &mx.shadow_mutex,
                                                    &count, timed, XN_INFINITE);
-
        if (err == EINTR) {
+               unsigned sigpending = 0, kicked = 0;
                do {
+                       spl_t s;
+                       xnlock_get_irqsave(&nklock, s);
+                       sigpending |= xnthread_sigpending(cur);
+                       xnthread_set_sigpending(cur, 0);
+
+                       kicked = xnthread_test_info(cur, XNKICKED);
                        xnthread_clear_info(cur, XNKICKED);
+                       xnlock_put_irqrestore(&nklock, s);
+
                        err =
                            pse51_cond_timedwait_epilogue(cur, &cnd.shadow_cond,
                                                          &mx.shadow_mutex,
                                                          count);
                }
                while (err == -EINTR);
-               xnthread_set_info(cur, XNKICKED);
+               if (kicked)
+                       xnthread_set_info(cur, XNKICKED);
+               if (sigpending) {
+                       spl_t s;
+                       xnlock_get_irqsave(&nklock, s);
+                       sigpending |= xnthread_sigpending(cur);
+                       xnthread_set_sigpending(cur, sigpending);
+                       xnlock_put_irqrestore(&nklock, s);
+               }
                err = EINTR;
        }
 
@@ -2771,7 +2787,8 @@ static xnsysent_t __systab[] = {
        [__pse51_clock_getres] = {&__clock_getres, __xn_exec_any},
        [__pse51_clock_gettime] = {&__clock_gettime, __xn_exec_any},
        [__pse51_clock_settime] = {&__clock_settime, __xn_exec_any},
-       [__pse51_clock_nanosleep] = {&__clock_nanosleep, __xn_exec_primary},
+       [__pse51_clock_nanosleep] = {&__clock_nanosleep, 
+                                    __xn_exec_primary | __xn_exec_norestart},
        [__pse51_mutex_init] = {&__pthread_mutex_init, __xn_exec_any},
        [__pse51_mutex_destroy] = {&__pthread_mutex_destroy, __xn_exec_any},
        [__pse51_mutex_lock] = {&__pthread_mutex_lock, __xn_exec_primary},
@@ -2786,7 +2803,7 @@ static xnsysent_t __systab[] = {
        [__pse51_cond_init] = {&__pthread_cond_init, __xn_exec_any},
        [__pse51_cond_destroy] = {&__pthread_cond_destroy, __xn_exec_any},
        [__pse51_cond_wait_prologue] =
-           {&__pthread_cond_wait_prologue, __xn_exec_primary},
+           {&__pthread_cond_wait_prologue, __xn_exec_primary | 
__xn_exec_norestart},
        [__pse51_cond_wait_epilogue] =
            {&__pthread_cond_wait_epilogue, __xn_exec_primary},
        [__pse51_cond_signal] = {&__pthread_cond_signal, __xn_exec_any},


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

Reply via email to