Module: xenomai-2.5
Branch: master
Commit: 051201a5e6a206072da28370e9b2715b050342aa
URL:    
http://git.xenomai.org/?p=xenomai-2.5.git;a=commit;h=051201a5e6a206072da28370e9b2715b050342aa

Author: Gilles Chanteperdrix <gilles.chanteperd...@xenomai.org>
Date:   Wed Feb 10 19:44:31 2010 +0100

nucleus: wake a select'ing thread up when closing a fd.

---

 ksrc/nucleus/select.c |   15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/ksrc/nucleus/select.c b/ksrc/nucleus/select.c
index fd56bfb..29be0bc 100644
--- a/ksrc/nucleus/select.c
+++ b/ksrc/nucleus/select.c
@@ -131,7 +131,8 @@ int xnselect_bind(struct xnselect *select_block,
                __FD_SET(index, &selector->fds[type].pending);
                if (xnselect_wakeup(selector))
                        xnpod_schedule();
-       }
+       } else
+               __FD_CLR(index, &selector->fds[type].pending);
 
        return 0;
 }
@@ -178,6 +179,7 @@ EXPORT_SYMBOL_GPL(__xnselect_signal);
 void xnselect_destroy(struct xnselect *select_block)
 {
        xnholder_t *holder;
+       int resched;
        spl_t s;
 
        xnlock_get_irqsave(&nklock, s);
@@ -190,8 +192,13 @@ void xnselect_destroy(struct xnselect *select_block)
 
                __FD_CLR(binding->bit_index,
                         &selector->fds[binding->type].expected);
-               __FD_CLR(binding->bit_index,
-                        &selector->fds[binding->type].pending);
+               if (!__FD_ISSET(binding->bit_index,
+                               &selector->fds[binding->type].pending)) {
+                       __FD_SET(binding->bit_index,
+                                &selector->fds[binding->type].pending);
+                       if (xnselect_wakeup(selector))
+                               resched = 1;
+               }
                removeq(&selector->bindings, &binding->slink);
                xnlock_put_irqrestore(&nklock, s);
 
@@ -199,6 +206,8 @@ void xnselect_destroy(struct xnselect *select_block)
                
                xnlock_get_irqsave(&nklock, s);
        }
+       if (resched)
+               xnpod_schedule();
        xnlock_put_irqrestore(&nklock, s);
 }
 EXPORT_SYMBOL_GPL(xnselect_destroy);


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

Reply via email to