From: Jean Tourrilhes <jt@bougret.hpl.hp.com>
To: Linus Torvalds <torvalds@transmeta.com>,
irda-users@lists.sourceforge.net,
Linux kernel mailing list <linux-kernel@vger.kernel.org>
Subject: [PATCH] : ir256_sock_connect_cli.diff
Date: Tue, 5 Mar 2002 14:34:31 -0800 [thread overview]
Message-ID: <20020305143431.C1254@bougret.hpl.hp.com> (raw)
ir256_sock_connect_cli.diff :
---------------------------
o [CRITICA] Fix socket connect to remove dangerous cli()
<Tested on SMP>
--- linux/net/irda/af_irda.d4.c Mon Mar 4 14:54:38 2002
+++ linux/net/irda/af_irda.c Mon Mar 4 17:07:45 2002
@@ -1022,28 +1022,26 @@ static int irda_connect(struct socket *s
/* Now the loop */
if (sk->state != TCP_ESTABLISHED && (flags & O_NONBLOCK))
return -EINPROGRESS;
-
- cli(); /* To avoid races on the sleep */
-
- /* A Connect Ack with Choke or timeout or failed routing will go to
- * closed. */
+
+ /* Here, there is a race condition : the state may change between
+ * our test and the sleep, via irda_connect_confirm().
+ * The way to workaround that is to sleep with a timeout, so that
+ * we don't sleep forever and check the state when waking up.
+ * 50ms is plenty good enough, because the LAP is already connected.
+ * Jean II */
while (sk->state == TCP_SYN_SENT) {
- interruptible_sleep_on(sk->sleep);
+ interruptible_sleep_on_timeout(sk->sleep, HZ/20);
if (signal_pending(current)) {
- sti();
return -ERESTARTSYS;
}
}
if (sk->state != TCP_ESTABLISHED) {
- sti();
sock->state = SS_UNCONNECTED;
return sock_error(sk); /* Always set at this point */
}
sock->state = SS_CONNECTED;
-
- sti();
/* At this point, IrLMP has assigned our source address */
self->saddr = irttp_get_saddr(self->tsap);
reply other threads:[~2002-03-05 22:35 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20020305143431.C1254@bougret.hpl.hp.com \
--to=jt@bougret.hpl.hp.com \
--cc=irda-users@lists.sourceforge.net \
--cc=jt@hpl.hp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@transmeta.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).