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

Author: Philippe Gerum <r...@xenomai.org>
Date:   Sun Sep  1 17:00:56 2013 +0200

lib/cobalt: fix signal bucket leakage upon immediate delivery

---

 kernel/cobalt/posix/signal.c |   15 +++++++++++++--
 1 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/kernel/cobalt/posix/signal.c b/kernel/cobalt/posix/signal.c
index 73a390b..9ebb12e 100644
--- a/kernel/cobalt/posix/signal.c
+++ b/kernel/cobalt/posix/signal.c
@@ -59,9 +59,17 @@ int cobalt_signal_deliver(struct cobalt_thread *thread,
        cobalt_copy_siginfo(sigp->si.si_code, swc->si, &sigp->si);
        cobalt_call_extension(signal_deliver, &thread->extref,
                              ret, swc->si, sigp);
-
        xnsynch_wakeup_one_sleeper(&thread->sigwait);
 
+       /*
+        * This is an immediate delivery bypassing any queuing, so we
+        * have to release the sigpending data right away before
+        * leaving.
+        */
+       if ((void *)sigp >= sigpending_mem &&
+           (void *)sigp < sigpending_mem + __SIGPOOL_SIZE)
+               list_add_tail(&sigp->next, &sigpending_pool);
+
        return 1;
 }
 EXPORT_SYMBOL_GPL(cobalt_signal_deliver);
@@ -134,8 +142,11 @@ struct cobalt_sigpending *cobalt_signal_alloc(void)
 {                              /* nklocked, IRQs off */
        struct cobalt_sigpending *sigp;
 
-       if (list_empty(&sigpending_pool))
+       if (list_empty(&sigpending_pool)) {
+               if (printk_ratelimit())
+                       printk(XENO_WARN "signal bucket pool underflows\n");
                return NULL;
+       }
 
        sigp = list_get_entry(&sigpending_pool, struct cobalt_sigpending, next);
        INIT_LIST_HEAD(&sigp->next);


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

Reply via email to