NetBSD Problem Report #47569
From www@NetBSD.org Thu Feb 14 21:33:55 2013
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
by www.NetBSD.org (Postfix) with ESMTP id 095C163EE79
for <gnats-bugs@gnats.NetBSD.org>; Thu, 14 Feb 2013 21:33:55 +0000 (UTC)
Message-Id: <20130214213354.33D9263EE79@www.NetBSD.org>
Date: Thu, 14 Feb 2013 21:33:54 +0000 (UTC)
From: uwe@NetBSD.org
Reply-To: uwe@NetBSD.org
To: gnats-bugs@NetBSD.org
Subject: SOCK_NONBLOCK flag to socket(2) doesn't work
X-Send-Pr-Version: www-1.0
>Number: 47569
>Category: kern
>Synopsis: SOCK_NONBLOCK flag to socket(2) doesn't work
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: kern-bug-people
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu Feb 14 21:35:01 +0000 2013
>Closed-Date: Mon Feb 18 03:48:32 +0000 2013
>Last-Modified: Fri Jul 21 04:00:01 +0000 2017
>Originator: Valery Ushakov
>Release: NetBSD 6
>Organization:
>Environment:
>Description:
SOCK_NONBLOCK flag is documented in socket(2) man page to make socket
non-blocking. Unfortunately it doesn't.
A socket created with that flag has O_NONBLOCK in flags (as per fcntl
F_GETFL), but it seems the flag is not reflected as SS_NBIO flag in
socket::so_state correctly.
A socket created without SOCK_NONBLOCK can be made nonblocking with
either fcntl(F_SETFL) that adds O_NONBLOCK, or with ioctl(FIONBIO).
A socket created with SOCK_NONBLOCK is made nonblocking with
ioctl(FIONBIO). On the other hand since O_NONBLOCK is already set in
flags, fcntl(F_SETFL) doesn't help and you would need to do two
F_SETFL once to clear O_NONBLOCK (from SOCK_NONBLOCK) then another to
set it (and correctly push it out to so_state).
>How-To-Repeat:
I don't have a minimized test case handy and don't have time to write
one right now, but it's trivial code along the lines of
s = socket(PF_INET, SOCK_STREAM | SOCK_NONBLOCK, 0);
status = connect(s, ...);
/* check errno */
where the sockaddr is e.g. some non-assigned IP that would cause
ETIMEDOUT.
This code will be blocked in connect(2) and will eventually return -1
and set ETIMEDOUT instead of returning immediately and setting
EINPROGRESS.
If ioctl(FIONBIO) is added before connect(2), connect(2) does become
nonblocking.
>Fix:
>Release-Note:
>Audit-Trail:
From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/47569 CVS commit: src/sys/kern
Date: Thu, 14 Feb 2013 16:57:59 -0500
Module Name: src
Committed By: christos
Date: Thu Feb 14 21:57:59 UTC 2013
Modified Files:
src/sys/kern: uipc_socket.c uipc_syscalls.c
Log Message:
PR/47569: Valery Ushakov: SOCK_NONBLOCK does not work because it does not
set SS_NBIO.
XXX: there are too many flags that mean the same thing in too many places,
and too many flags that mean the same thing and are different.
To generate a diff of this commit:
cvs rdiff -u -r1.212 -r1.213 src/sys/kern/uipc_socket.c
cvs rdiff -u -r1.159 -r1.160 src/sys/kern/uipc_syscalls.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: "Julian Coleman" <jdc@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/47569 CVS commit: [netbsd-6] src/sys/kern
Date: Thu, 14 Feb 2013 22:13:59 +0000
Module Name: src
Committed By: jdc
Date: Thu Feb 14 22:13:59 UTC 2013
Modified Files:
src/sys/kern [netbsd-6]: uipc_socket.c uipc_syscalls.c
Log Message:
Pull up revisions:
src/sys/kern/uipc_socket.c revision 1.213
src/sys/kern/uipc_syscalls.c revision 1.160
(requested by christos in ticket #822).
PR/47569: Valery Ushakov: SOCK_NONBLOCK does not work because it does not
set SS_NBIO.
XXX: there are too many flags that mean the same thing in too many places=
,
and too many flags that mean the same thing and are different.
To generate a diff of this commit:
cvs rdiff -u -r1.209.2.1 -r1.209.2.2 src/sys/kern/uipc_socket.c
cvs rdiff -u -r1.154.2.2 -r1.154.2.3 src/sys/kern/uipc_syscalls.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: David Holland <dholland-bugs@netbsd.org>
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: kern/47569: SOCK_NONBLOCK flag to socket(2) doesn't work
Date: Fri, 15 Feb 2013 05:31:54 +0000
On Thu, Feb 14, 2013 at 09:35:01PM +0000, uwe@NetBSD.org wrote:
> A socket created with that flag has O_NONBLOCK in flags (as per fcntl
> F_GETFL), but it seems the flag is not reflected as SS_NBIO flag in
> socket::so_state correctly.
Does this need to go into -5, or is it done?
--
David A. Holland
dholland@netbsd.org
From: christos@zoulas.com (Christos Zoulas)
To: gnats-bugs@NetBSD.org, kern-bug-people@netbsd.org,
gnats-admin@netbsd.org, netbsd-bugs@netbsd.org, uwe@NetBSD.org
Cc:
Subject: Re: kern/47569: SOCK_NONBLOCK flag to socket(2) doesn't work
Date: Fri, 15 Feb 2013 07:39:47 -0500
On Feb 15, 5:35am, dholland-bugs@netbsd.org (David Holland) wrote:
-- Subject: Re: kern/47569: SOCK_NONBLOCK flag to socket(2) doesn't work
| On Thu, Feb 14, 2013 at 09:35:01PM +0000, uwe@NetBSD.org wrote:
| > A socket created with that flag has O_NONBLOCK in flags (as per fcntl
| > F_GETFL), but it seems the flag is not reflected as SS_NBIO flag in
| > socket::so_state correctly.
|
| Does this need to go into -5, or is it done?
This is done; the flag does not exist in 5.
christos
State-Changed-From-To: open->closed
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Mon, 18 Feb 2013 03:48:32 +0000
State-Changed-Why:
fixed, thanks
From: "Soren Jacobsen" <snj@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/47569 CVS commit: [netbsd-6-0] src/sys/kern
Date: Fri, 21 Jul 2017 03:55:56 +0000
Module Name: src
Committed By: snj
Date: Fri Jul 21 03:55:56 UTC 2017
Modified Files:
src/sys/kern [netbsd-6-0]: uipc_socket.c uipc_syscalls.c
Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1453):
sys/kern/uipc_socket.c: revision 1.213
sys/kern/uipc_syscalls.c: revision 1.160
PR/47569: Valery Ushakov: SOCK_NONBLOCK does not work because it does not
set SS_NBIO.
XXX: there are too many flags that mean the same thing in too many places,
and too many flags that mean the same thing and are different.
To generate a diff of this commit:
cvs rdiff -u -r1.209.2.1.4.2 -r1.209.2.1.4.3 src/sys/kern/uipc_socket.c
cvs rdiff -u -r1.154.2.1.4.2 -r1.154.2.1.4.3 src/sys/kern/uipc_syscalls.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2014
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.