From: Oleg Nesterov <oleg@tv-sign.ru>
To: Michael Kerrisk <mtk.manpages@googlemail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
David Miller <davem@davemloft.net>,
Davide Libenzi <davidel@xmailserver.org>,
Alan Cox <alan@redhat.com>, Ulrich Drepper <drepper@redhat.com>,
Jakub Jelinek <jakub@redhat.com>,
lkml <linux-kernel@vger.kernel.org>,
Linus Torvalds <torvalds@linux-foundation.org>,
netdev <netdev@vger.kernel.org>,
Roland McGrath <roland@redhat.com>,
Christoph Hellwig <hch@lst.de>
Subject: Re: sys_paccept: disable paccept() until API design is resolved
Date: Tue, 16 Sep 2008 17:04:38 +0400 [thread overview]
Message-ID: <20080916130438.GA261@tv-sign.ru> (raw)
In-Reply-To: <48CFA10D.2010106@gmail.com>
On 09/16, Michael Kerrisk wrote:
>
> * The behavior of paccept() when interrupted by a signal is IMO
> strange: the kernel restarts the system call if SA_RESTART was set
> for the handler. I think that it should not do this -- that it
> should behave consistently with paccept()/ppoll()/epoll_pwait(),
> which never restart, regardless of SA_RESTART. The reasoning here
> is that the very purpose of paccept() is to wait for a connection
> or a signal, and that restarting in the latter case is probably
> never useful. (Note: Roland disagrees on this point, believing
> that rather paccept() should be consistent with accept() in its
> behavior wrt EINTR
> (http://thread.gmane.org/gmane.linux.kernel/723953/focus=732255).)
Also, the implementation of sys_paccept() is not "perfect", imho.
sys_paccept:
ret = do_accept(...);
if (ret < 0 && signal_pending()) {
set_restore_sigmask();
return ret;
}
It doesn't check that ret == ERESTARTSYS/EINTR. I can't say this
is bug, but let's suppose that do_accept() returns (say) -EINVAL,
and then the task is interrupted by the signal.
Now, if the signal comes after sys_paccept() checks signal_pending(),
we return -EINVAL, and the signal handler runs with the original
current->blocked mask, as expected.
However, if the signal happens in the window before signal_pending(),
we still return -EINVAL, but the signal handler runs with
->blocked == sigmask. A bit odd, but probably harmless.
Note also that unless I misread the code, do_paccept() returns
ERESTARTSYS or EINTR depending on ->sk_rcvtimeo. Yes, it is very
clear why sock_intr_errno() does this, but this doesn't make the
behaviour of paccept() more understandable.
Oleg.
next prev parent reply other threads:[~2008-09-16 13:04 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-16 12:05 sys_paccept: disable paccept() until API design is resolved Michael Kerrisk
2008-09-16 13:04 ` Oleg Nesterov [this message]
2008-09-16 23:17 ` Ulrich Drepper
2008-09-17 0:24 ` Michael Kerrisk
2008-09-17 16:46 ` Evgeniy Polyakov
2008-09-17 1:22 ` Nick Piggin
2008-09-17 6:50 ` Rémi Denis-Courmont
2008-09-17 14:30 ` Oleg Nesterov
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=20080916130438.GA261@tv-sign.ru \
--to=oleg@tv-sign.ru \
--cc=akpm@linux-foundation.org \
--cc=alan@redhat.com \
--cc=davem@davemloft.net \
--cc=davidel@xmailserver.org \
--cc=drepper@redhat.com \
--cc=hch@lst.de \
--cc=jakub@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mtk.manpages@googlemail.com \
--cc=netdev@vger.kernel.org \
--cc=roland@redhat.com \
--cc=torvalds@linux-foundation.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 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).