All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
To: Jan Kiszka <jan.kiszka@domain.hid>
Cc: xenomai-core <xenomai@xenomai.org>
Subject: Re: [Xenomai-core] xnselect_destroy fails to wake up waiters
Date: Wed, 10 Feb 2010 18:31:23 +0100	[thread overview]
Message-ID: <4B72ED6B.5010805@domain.hid> (raw)
In-Reply-To: <4B72DB97.1020203@domain.hid>

Jan Kiszka wrote:
> Hi Gilles,
> 
> I tend to think that xnselect_destroy should signal an event on the
> dying fd instead of just clearing the binding. The task blocking on
> select currently does not get a hint that the fd is dead and will block
> on select until some other event arrives. That's unfortunately not
> standard conforming.

Could you test the following patch? The fd will be in the "pending" set
until the fd is reused, but that should be harmless as long as the fd is
not in the "expected" set.

diff --git a/ksrc/nucleus/select.c b/ksrc/nucleus/select.c
index fd56bfb..17c5e0b 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,11 +192,18 @@ 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);
 
+		if (resched)
+			xnpod_schedule();
 		xnfree(binding);
 		
 		xnlock_get_irqsave(&nklock, s);

-- 
					    Gilles.


  parent reply	other threads:[~2010-02-10 17:31 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-10 16:15 [Xenomai-core] xnselect_destroy fails to wake up waiters Jan Kiszka
2010-02-10 16:19 ` Gilles Chanteperdrix
2010-02-10 16:32 ` Gilles Chanteperdrix
2010-02-10 16:37   ` Jan Kiszka
2010-02-10 16:51     ` Gilles Chanteperdrix
2010-02-10 17:07       ` Jan Kiszka
2010-02-10 17:17         ` Gilles Chanteperdrix
2010-02-10 17:31 ` Gilles Chanteperdrix [this message]
2010-02-10 18:26   ` Jan Kiszka
2010-02-10 18:51     ` Gilles Chanteperdrix
2010-02-10 18:59       ` Jan Kiszka

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4B72ED6B.5010805@domain.hid \
    --to=gilles.chanteperdrix@xenomai.org \
    --cc=jan.kiszka@domain.hid \
    --cc=xenomai@xenomai.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.