diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2010-01-15 15:40:05 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2010-01-15 15:40:05 +0000 |
commit | 0d6531551b6bf4037017c97d7f7ece5b83739601 (patch) | |
tree | 7fa8946d313748126bbe721da0b66f51e6094493 /winsup/cygwin/fhandler_socket.cc | |
parent | 14c800a5ba66195a80dfc02ffb0ea7da5f737bd7 (diff) | |
download | newlib-0d6531551b6bf4037017c97d7f7ece5b83739601.zip newlib-0d6531551b6bf4037017c97d7f7ece5b83739601.tar.gz newlib-0d6531551b6bf4037017c97d7f7ece5b83739601.tar.bz2 |
* cygwin.din (accept4): Export.
* fhandler.h (fhandler_socket::accept4): Rename from accept. Take
additional flag parameter.
* fhandler_socket.cc (fhandler_socket::accept4): Ditto. Handle
SOCK_NONBLOCK and SOCK_CLOEXEC flags.
* net.cc (cygwin_socket): Handle SOCK_NONBLOCK and SOCK_CLOEXEC flags
in type. Check for invalid flag values.
(socketpair): Ditto.
(cygwin_accept): Accommodate renaming of fhandler_socket::accept
function to accept4.
(accept4): New function.
* posix.sgml: Mention accept4 as GNU extensions.
* include/cygwin/socket.h (SOCK_NONBLOCK): Define.
(SOCK_CLOEXEC): Define.
(_SOCK_FLAG_MASK): Define when building Cygwin.
* include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump.
* include/sys/socket.h (accept4): Declare.
Diffstat (limited to 'winsup/cygwin/fhandler_socket.cc')
-rw-r--r-- | winsup/cygwin/fhandler_socket.cc | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/winsup/cygwin/fhandler_socket.cc b/winsup/cygwin/fhandler_socket.cc index f676f85..b520193 100644 --- a/winsup/cygwin/fhandler_socket.cc +++ b/winsup/cygwin/fhandler_socket.cc @@ -1,6 +1,7 @@ /* fhandler_socket.cc. See fhandler.h for a description of the fhandler classes. - Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Red Hat, Inc. + Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, + 2009, 2010 Red Hat, Inc. This file is part of Cygwin. @@ -1193,7 +1194,7 @@ fhandler_socket::listen (int backlog) } int -fhandler_socket::accept (struct sockaddr *peer, int *len) +fhandler_socket::accept4 (struct sockaddr *peer, int *len, int flags) { /* Allows NULL peer and len parameters. */ struct sockaddr_storage lpeer; @@ -1216,7 +1217,6 @@ fhandler_socket::accept (struct sockaddr *peer, int *len) sock->set_addr_family (get_addr_family ()); sock->set_socket_type (get_socket_type ()); sock->async_io (async_io ()); - sock->set_nonblocking (is_nonblocking ()); if (get_addr_family () == AF_LOCAL) { sock->set_sun_path (get_sun_path ()); @@ -1236,6 +1236,10 @@ fhandler_socket::accept (struct sockaddr *peer, int *len) } } } + sock->set_nonblocking (flags & SOCK_NONBLOCK + ? true : is_nonblocking ()); + if (flags & SOCK_CLOEXEC) + sock->set_close_on_exec (true); /* No locking necessary at this point. */ sock->wsock_events->events = wsock_events->events | FD_WRITE; sock->wsock_events->owner = wsock_events->owner; |