From 152a9caf58265c5a966f978df1ef4f8adbd2543c Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Sat, 22 Oct 2005 15:11:49 +0000 Subject: * fhandler.h (class fhandler_socket): Add timeout parameter to wait() method. * fhandler_socket.cc (fhandler_socket::connect): Use event driven technique (prepare/wait/release) to implement interuptible connect. (fhandler_socket::wait): Add timeout parameter. Allow FD_CONNECT handling. * net.cc (cygwin_connect): Remove braindead workaround for allowing blocking connect. That's entirely in fhandler_socket::connect now. --- winsup/cygwin/net.cc | 51 +-------------------------------------------------- 1 file changed, 1 insertion(+), 50 deletions(-) (limited to 'winsup/cygwin/net.cc') diff --git a/winsup/cygwin/net.cc b/winsup/cygwin/net.cc index 91ee74a20..eccf0635f 100644 --- a/winsup/cygwin/net.cc +++ b/winsup/cygwin/net.cc @@ -775,56 +775,7 @@ cygwin_connect (int fd, const struct sockaddr *name, int namelen) if (efault.faulted (EFAULT) || !fh) res = -1; else - { - bool was_blocking = false; - if (!fh->is_nonblocking ()) - { - int nonblocking = 1; - fh->ioctl (FIONBIO, &nonblocking); - was_blocking = true; - } - res = fh->connect (name, namelen); - if (was_blocking) - { - if (res == -1 && get_errno () == EINPROGRESS) - { - size_t fds_size = howmany (fd + 1, NFDBITS) * sizeof (fd_mask); - fd_set *write_fds = (fd_set *) alloca (fds_size); - fd_set *except_fds = (fd_set *) alloca (fds_size); - memset (write_fds, 0, fds_size); - memset (except_fds, 0, fds_size); - FD_SET (fd, write_fds); - FD_SET (fd, except_fds); - res = cygwin_select (fd + 1, NULL, write_fds, except_fds, NULL); - if (res > 0 && FD_ISSET (fd, except_fds)) - { - res = -1; - for (;;) - { - int err; - int len = sizeof err; - cygwin_getsockopt (fd, SOL_SOCKET, SO_ERROR, - (void *) &err, &len); - if (err) - { - set_errno (err); - break; - } - low_priority_sleep (0); - } - } - else if (res > 0) - res = 0; - else - { - WSASetLastError (WSAEINPROGRESS); - set_winsock_errno (); - } - } - int nonblocking = 0; - fh->ioctl (FIONBIO, &nonblocking); - } - } + res = fh->connect (name, namelen); syscall_printf ("%d = connect (%d, %p, %d)", res, fd, name, namelen); -- cgit v1.2.3