Fri Jan 15 20:23:00 GMT 2010
On Jan 15 15:04, Pierre A. Humblet wrote:
> I see an issue with accept/accept4 and was going to ask you how to
> handle it.
> Before your changes in Cygwin the socket returned by accept had the
> same blocking (and async) property as the listening socket.
> Apparently this conforms to BSD but not to Linux (even old versions
> without accept4),
> POSIX is silent on the topic.
> After your changes the new socket is non-blocking if either the
> listening socket was non-blocking or SOCK_NONBLOCK is specified. This
> does not conform to Linux.
> Why not have accept4 conform to Linux but keep the old behavior of accept by
> changing accept in net.cc to
> res = fh->accept4 (peer, len, fh->is_nonblocking () ? SOCK_NONBLOCK : 0);
> There is a similar Linux discrepancy with async_io.
I have no problem to change the SOCK_NONBLOCK stuff as you proposed.
I don't like the idea to introduce such a new flag for ASYNC which
doesn't exist on Linux, though. How important is the async mode anyway?
Will we really get any problems with existing apps if we switch to the
Linux behaviour for async?
RCS file: /cvs/src/src/winsup/cygwin/fhandler_socket.cc,v
retrieving revision 1.257
diff -u -p -r1.257 fhandler_socket.cc
--- fhandler_socket.cc 15 Jan 2010 15:40:05 -0000 1.257
+++ fhandler_socket.cc 15 Jan 2010 20:16:56 -0000
@@ -1216,7 +1216,6 @@ fhandler_socket::accept4 (struct sockadd
fhandler_socket *sock = (fhandler_socket *) res_fd;
sock->set_addr_family (get_addr_family ());
sock->set_socket_type (get_socket_type ());
- sock->async_io (async_io ());
if (get_addr_family () == AF_LOCAL)
sock->set_sun_path (get_sun_path ());
@@ -1236,10 +1235,11 @@ fhandler_socket::accept4 (struct sockadd
- sock->set_nonblocking (flags & SOCK_NONBLOCK
- ? true : is_nonblocking ());
+ sock->set_nonblocking (flags & SOCK_NONBLOCK);
if (flags & SOCK_CLOEXEC)
+ WSAEventSelect (sock->get_socket (), wsock_evt, EVENT_MASK);
+ sock->async_io (false);
/* No locking necessary at this point. */
sock->wsock_events->events = wsock_events->events | FD_WRITE;
sock->wsock_events->owner = wsock_events->owner;
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Project Co-Leader cygwin AT cygwin DOT com
More information about the Cygwin-patches