Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2003-02-20 17:14:37 +0300
committerCorinna Vinschen <corinna@vinschen.de>2003-02-20 17:14:37 +0300
commit518f5d4935235da84435c69d254b826dee5186f2 (patch)
treed43f1193c288dd2f767221d9ff8e7573fc84a90c /winsup/cygwin/fhandler_socket.cc
parent1374b148ba05b8ff93032e3c5cfc4c9e6a85e572 (diff)
* fhandler_disk_file.cc (fhandler_disk_file::opendir): Check descriptor
created by cygheap_fdnew constructor. * fhandler_virtual.cc (fhandler_virtual::opendir): Ditto. * fhandler_socket.cc (fhandler_socket::accept): Ditto and move creation of file descriptor behind blocking OS call. * net.cc (cygwin_socket): Ditto. (cygwin_rcmd): Ditto. (cygwin_rresvport): Ditto. (cygwin_rexec): Ditto. (socketpair): Ditto.
Diffstat (limited to 'winsup/cygwin/fhandler_socket.cc')
-rw-r--r--winsup/cygwin/fhandler_socket.cc30
1 files changed, 19 insertions, 11 deletions
diff --git a/winsup/cygwin/fhandler_socket.cc b/winsup/cygwin/fhandler_socket.cc
index 0e10ad5c6..6c867f927 100644
--- a/winsup/cygwin/fhandler_socket.cc
+++ b/winsup/cygwin/fhandler_socket.cc
@@ -484,7 +484,6 @@ fhandler_socket::accept (struct sockaddr *peer, int *len)
WSAEVENT ev[2] = { WSA_INVALID_EVENT, signal_arrived };
BOOL secret_check_failed = FALSE;
BOOL in_progress = FALSE;
- cygheap_fdnew res_fd;
/* Allows NULL peer and len parameters. */
struct sockaddr_in peer_dummy;
@@ -593,19 +592,28 @@ fhandler_socket::accept (struct sockaddr *peer, int *len)
}
}
- if (res_fd < 0)
- /* FIXME: what is correct errno? */;
- else if ((SOCKET) res == (SOCKET) INVALID_SOCKET)
+ if ((SOCKET) res == (SOCKET) INVALID_SOCKET)
set_winsock_errno ();
else
{
- fhandler_socket* res_fh = fdsock (res_fd, get_name (), res);
- if (get_addr_family () == AF_LOCAL)
- res_fh->set_sun_path (get_sun_path ());
- res_fh->set_addr_family (get_addr_family ());
- res_fh->set_socket_type (get_socket_type ());
- res_fh->set_connect_state (CONNECTED);
- res = res_fd;
+ cygheap_fdnew res_fd;
+ fhandler_socket* res_fh = NULL;
+ if (res_fd >= 0)
+ res_fh = fdsock (res_fd, get_name (), res);
+ if (res_fh)
+ {
+ if (get_addr_family () == AF_LOCAL)
+ res_fh->set_sun_path (get_sun_path ());
+ res_fh->set_addr_family (get_addr_family ());
+ res_fh->set_socket_type (get_socket_type ());
+ res_fh->set_connect_state (CONNECTED);
+ res = res_fd;
+ }
+ else
+ {
+ closesocket (res);
+ res = -1;
+ }
}
done: