All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marcel Holtmann <marcel@holtmann.org>
To: Jean Tourrilhes <jt@hpl.hp.com>
Cc: Max Krasnyansky <maxk@qualcomm.com>,
	BlueZ Mailing List <bluez-devel@lists.sourceforge.net>
Subject: [Bluez-devel] Re: L2CAP non-blocking socket nasty race conditions
Date: Wed, 04 Feb 2004 08:17:24 +0100	[thread overview]
Message-ID: <1075879044.13285.151.camel@pegasus> (raw)
In-Reply-To: <20040204015825.GA2217@bougret.hpl.hp.com>

Hi Jean,

> 	I've just managed to reproduce and track a few bug that so far
> were escaping me. There is a race condition in the accept() code for
> non-blocking L2CAP sockets, and a similar one in sendmsg. Or maybe
> it's just that my code is too fast ;-)

do you have a simple test code to reproduce it?

> 	This is the accept race :
> 	1) L2CAP socket in non blocking mode, because program waiting
> on multiple outputs.
> 	2) Wait on socket to be readable with poll/select.
> 	3) When socket is ready, accept() it and do what we have to do.
> 	4) When the race occur, accept() return an error (EAGAIN).
> 	5) We don't touch the socket and go back to poll/select.
> 	6) Poll/select returns immediately (socket is still readable).
> 	7) We attempt the accept(), EAGAIN, goto (5)

Is this an endless loop? Or do accept() succeeds after some time?

BTW why must a listen socket non-blocking? The listen() command itself
doesn't block and I don't see any need for a non-blocking listen socket.

> 	I didn't managed to fully identify the sendmsg race, but I
> goes like this :
> 	1) Open L2CAP socket in non blocking mode, because program
> waiting on multiple outputs.
> 	2) Connect to BT peer.
> 	3) Wait on socket to be writeable with poll/select.
> 	4) When socket is ready, sendmsg() and do what we have to do.
> 	5) When the race occur, sendmsg() return an error (ENOTCONN).
> 	...
> 
> 	I looked at way to fix the code, but it's not a quick fix and
> there is multiple way to attack the problem. So, if one of you could
> have a look at it...

Is this on a listen/accepted socket or is this a simple connection?

> 	Below you will find a self explanatory log of the kernel
> showing the problem with accept. The first accept was successful (no
> problem), the second one was racy.

>>From the logfile function names I assume this is a 2.6 kernel. Do you
see the same behaviour on 2.4?

Regards

Marcel




-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel

  reply	other threads:[~2004-02-04  7:17 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-02-04  1:58 L2CAP non-blocking socket nasty race conditions Jean Tourrilhes
2004-02-04  7:17 ` Marcel Holtmann [this message]
2004-02-04 17:58   ` Jean Tourrilhes
2004-02-04 19:58     ` [Bluez-devel] " Marcel Holtmann
2004-02-04 21:45       ` Jean Tourrilhes
2004-02-05  1:00         ` [Bluez-devel] " Marcel Holtmann
2004-02-05  1:11           ` Jean Tourrilhes
2004-02-05  1:30             ` [Bluez-devel] " Marcel Holtmann
2004-02-05  1:40               ` Jean Tourrilhes
2004-02-05  2:21                 ` [Bluez-devel] " Marcel Holtmann
2004-02-05  2:26                   ` Jean Tourrilhes
2004-02-05  2:36                     ` [Bluez-devel] " Marcel Holtmann
2004-02-05  2:42                       ` Jean Tourrilhes
2004-02-05  3:30                       ` Jean Tourrilhes
2004-02-05 13:49                         ` [Bluez-devel] " Marcel Holtmann
2004-02-05 17:19                           ` Jean Tourrilhes
2004-02-05 18:17                             ` [Bluez-devel] " Marcel Holtmann
2004-02-05 23:13                               ` Jean Tourrilhes
2004-02-05 23:37                                 ` [Bluez-devel] " Marcel Holtmann
2004-02-05 23:43                                   ` Jean Tourrilhes
2004-02-04 11:23 ` [Bluez-devel] bluez & qos Mauro Tortonesi
2004-02-04 11:36   ` Marcel Holtmann
2004-02-04 17:46   ` [Bluez-devel] " Jean Tourrilhes
2004-02-05 10:46     ` Mauro Tortonesi
2004-02-05 17:22       ` Jean Tourrilhes

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=1075879044.13285.151.camel@pegasus \
    --to=marcel@holtmann.org \
    --cc=bluez-devel@lists.sourceforge.net \
    --cc=jt@hpl.hp.com \
    --cc=maxk@qualcomm.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 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.