From: "Theodore Ts'o" <tytso@mit.edu>
To: Paolo Ornati <ornati@fastwebnet.it>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: Lack of Documentation about SA_RESTART...
Date: Tue, 12 Jul 2005 14:16:35 -0400 [thread overview]
Message-ID: <20050712181635.GA7441@thunk.org> (raw)
In-Reply-To: <20050712172504.1216a174@localhost>
On Tue, Jul 12, 2005 at 05:25:04PM +0200, Paolo Ornati wrote:
> Hmmm... no, no. A connect() on non-blocking socket will NEVER return
> EINTR. SUSV3 and Linux code agree.
>
> A syscall isn't magically interrupted if a signal arrives... it's the
> syscall that must check for pending signals and do the proper action
> (usually it will return with -EINTR or -ERESTARTSYS).
>
> A connect() on a blocking socket is something like this (very
> approssimative):
>
> 1) code to activate the connection
> 2) sleep waiting for something (connection ready / signal received...)
> 3) if connection is ready then return 0, else if there are pending
> signals return -ERESTARTSYS
>
> With non-blocking socket the syscall never sleeps, and never checks for
> pending signals.
>
> Look at "net/ipv4/af_inet.c": in particular at "net_wait_for_connect"
> and its usage in "inet_stream_connect".
Yes, do look at that. From the latest 2.6 sources:
timeo = sock_sndtimeo(sk, flags & O_NONBLOCK);
if ((1 << sk->sk_state) & (TCPF_SYN_SENT | TCPF_SYN_RECV)) {
/* Error code is set above */
if (!timeo || !inet_wait_for_connect(sk, timeo))
goto out;
err = sock_intr_errno(timeo);
if (signal_pending(current))
goto out;
}
If the socket is non-blocking, then we don't call
inet_wiat_for_connect(), yes. But sock_intr_errno() will set the
error code to -EINTR if the socket is set to non-nonblocking (see
include/net/sock.h), and if a signal is pending, return it.
- Ted
next prev parent reply other threads:[~2005-07-12 18:19 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-07-11 10:32 Lack of Documentation about SA_RESTART Paolo Ornati
2005-07-11 14:34 ` Theodore Ts'o
2005-07-12 3:30 ` Philippe Troin
2005-07-12 8:43 ` Paolo Ornati
2005-07-12 8:38 ` Paolo Ornati
2005-07-12 10:10 ` Paolo Ornati
2005-07-12 12:04 ` Theodore Ts'o
2005-07-12 15:25 ` Paolo Ornati
2005-07-12 18:16 ` Theodore Ts'o [this message]
2005-07-13 7:45 ` Paolo Ornati
2005-07-24 0:30 ` Linus Torvalds
2005-07-24 7:28 ` Paolo Ornati
2005-07-24 14:56 ` Theodore Ts'o
2005-07-25 8:02 ` Paolo Ornati
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=20050712181635.GA7441@thunk.org \
--to=tytso@mit.edu \
--cc=linux-kernel@vger.kernel.org \
--cc=ornati@fastwebnet.it \
/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