From: Rainer Weikusat <rweikusat@mobileactivedefense.com>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: David Laight <David.Laight@ACULAB.COM>,
David Miller <davem@davemloft.net>,
netdev <netdev@vger.kernel.org>
Subject: Re: [PATCH] net: unix: non blocking recvmsg() should not return -EINTR
Date: Wed, 26 Mar 2014 19:46:05 +0000 [thread overview]
Message-ID: <87y4zw7ngi.fsf@sable.mobileactivedefense.com> (raw)
In-Reply-To: <1395847524.12610.208.camel@edumazet-glaptop2.roam.corp.google.com> (Eric Dumazet's message of "Wed, 26 Mar 2014 08:25:24 -0700")
Eric Dumazet <eric.dumazet@gmail.com> writes:
> On Wed, 2014-03-26 at 15:13 +0000, Rainer Weikusat wrote:
>
>> (This is from memory) If there's a thread blocked in recv and another
>> blocked on the lock and the kernel selects the thread blocked on the lock
>> for handling the signal, the signal won't be handled until some data is
>> received on the socket, ie, possibly never.
>
> Look at what we do for AF_INET. We handle this the proper way.
>
> If we are 'interrupted' by a signal while sleeping in lock_sock(),
> recvmsg() on a non blocking socket, we return -EAGAIN properly, not
> -EINTR.
>
> Fact that we potentially sleep to get the socket lock is hidden for the
> user, its an implementation detail of the kernel.
>
> We never return -EINTR, as stated in manpage for non blocking sockets.
There is (to the best of my knowledge) no man page which specifically
states that "socket is non-blocking" means "receive operation can't be
interrupted by a signal before any data was received" and telling
userspace "no data is available right now" when the operation was
actually interrupted by a signal before checking is still inaccurate.
The underlying problem would seem to be that a O_NONBLOCK call might
actually block forever in case a blocking receiver sits on the lock and
no data is ever received. Hence my original suggestion that it should
use a trylock-operation. But there are presumably downsides to this as
well, I didn't really think through it.
As I already wrote, this is a theoretical problem with no really
satisfactory solution minus noting that both 'nonblocking sockets' and
'multithreaded kernels' are somewhat alien concepts when considering the
system where EINTR originated (AFAIK). Also, it doesn't really matter:
If it was commonly assumed that O_NONBLOCK would imply 'no EINTR', the
kernel should behave accordingly for pragmatic reasons, not because
"commonly assumed" is the same as "obviously correct" (although it is
not uncommon for people to assume that common assumption are
must be obviously correct because they're common assumptions :-).
next prev parent reply other threads:[~2014-03-26 19:46 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-26 1:42 [PATCH] net: unix: non blocking recvmsg() should not return -EINTR Eric Dumazet
2014-03-26 13:17 ` Rainer Weikusat
2014-03-26 13:57 ` Rainer Weikusat
2014-03-26 14:09 ` Eric Dumazet
2014-03-26 14:25 ` Rainer Weikusat
2014-03-26 15:00 ` David Laight
2014-03-26 15:13 ` Rainer Weikusat
2014-03-26 15:25 ` Eric Dumazet
2014-03-26 15:33 ` Eric Dumazet
2014-03-26 19:46 ` Rainer Weikusat [this message]
2014-03-26 21:04 ` Rainer Weikusat
2014-03-27 9:36 ` David Laight
2014-03-27 12:40 ` Rainer Weikusat
2014-03-27 12:49 ` Jamal Hadi Salim
2014-03-27 13:02 ` Rainer Weikusat
2014-03-27 12:53 ` David Laight
2014-03-27 13:29 ` Rainer Weikusat
2014-03-26 21:05 ` David Miller
2014-03-26 21:21 ` Rainer Weikusat
2014-03-26 21:44 ` Eric Dumazet
2014-03-26 22:06 ` Rainer Weikusat
2014-03-26 22:35 ` Eric Dumazet
2014-03-26 22:51 ` Rainer Weikusat
2014-03-26 22:58 ` Eric Dumazet
2014-03-28 20:35 ` Rainer Weikusat
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=87y4zw7ngi.fsf@sable.mobileactivedefense.com \
--to=rweikusat@mobileactivedefense.com \
--cc=David.Laight@ACULAB.COM \
--cc=davem@davemloft.net \
--cc=eric.dumazet@gmail.com \
--cc=netdev@vger.kernel.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.