[lkml]   [2005]   [Jul]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    SubjectRe: Lack of Documentation about SA_RESTART...
    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
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to
    More majordomo info at
    Please read the FAQ at

     \ /
      Last update: 2005-07-12 20:25    [W:0.021 / U:28.596 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site