Module: xenomai-forge
Branch: next
Commit: ae9cb04d4dfaa378ebb524a3c03ac23493b11e76
URL:    
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=ae9cb04d4dfaa378ebb524a3c03ac23493b11e76

Author: Philippe Gerum <r...@xenomai.org>
Date:   Wed Jul  2 09:13:03 2014 +0200

lib/cobalt: turn sigwait*() calls into cancellation points

---

 lib/cobalt/signal.c |   28 ++++++++++++++++++++++------
 1 file changed, 22 insertions(+), 6 deletions(-)

diff --git a/lib/cobalt/signal.c b/lib/cobalt/signal.c
index 98422e1..50b77f5 100644
--- a/lib/cobalt/signal.c
+++ b/lib/cobalt/signal.c
@@ -27,36 +27,52 @@
 
 COBALT_IMPL(int, sigwait, (const sigset_t *set, int *sig))
 {
-       return -XENOMAI_SKINCALL2(__cobalt_muxid,
-                                 sc_cobalt_sigwait, set, sig);
+       int ret, oldtype;
+
+       pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldtype);
+
+       ret = -XENOMAI_SKINCALL2(__cobalt_muxid,
+                                sc_cobalt_sigwait, set, sig);
+
+       pthread_setcanceltype(oldtype, NULL);
+
+       return ret;
 }
 
 COBALT_IMPL(int, sigwaitinfo, (const sigset_t *set, siginfo_t *si))
 {
-       int ret;
+       int ret, oldtype;
+
+       pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldtype);
 
        ret = XENOMAI_SKINCALL2(__cobalt_muxid,
                                sc_cobalt_sigwaitinfo, set, si);
        if (ret < 0) {
                errno = -ret;
-               return -1;
+               ret = -1;
        }
 
+       pthread_setcanceltype(oldtype, NULL);
+
        return ret;
 }
 
 COBALT_IMPL(int, sigtimedwait, (const sigset_t *set, siginfo_t *si,
                                const struct timespec *timeout))
 {
-       int ret;
+       int ret, oldtype;
+
+       pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldtype);
 
        ret = XENOMAI_SKINCALL3(__cobalt_muxid,
                                sc_cobalt_sigtimedwait, set, si, timeout);
        if (ret < 0) {
                errno = -ret;
-               return -1;
+               ret = -1;
        }
 
+       pthread_setcanceltype(oldtype, NULL);
+
        return ret;
 }
 


_______________________________________________
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://www.xenomai.org/mailman/listinfo/xenomai-git

Reply via email to