apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stodd...@apache.org
Subject cvs commit: apr/network_io/win32 sockets.c
Date Thu, 12 Jul 2001 03:41:09 GMT
stoddard    01/07/11 20:41:09

  Modified:    network_io/win32 sockets.c
  Log:
  Handle the return from select correctly.
  
  Revision  Changes    Path
  1.59      +21 -4     apr/network_io/win32/sockets.c
  
  Index: sockets.c
  ===================================================================
  RCS file: /home/cvs/apr/network_io/win32/sockets.c,v
  retrieving revision 1.58
  retrieving revision 1.59
  diff -u -r1.58 -r1.59
  --- sockets.c	2001/07/12 02:23:27	1.58
  +++ sockets.c	2001/07/12 03:41:05	1.59
  @@ -282,8 +282,9 @@
   
       if (connect(sock->sock, (const struct sockaddr *)&sa->sa.sin,
                   sa->salen) == SOCKET_ERROR) {
  +        int rc;
           struct timeval tv, *tvptr;
  -        fd_set fdset;
  +        fd_set wfdset, efdset;
   
           rv = apr_get_netos_error();
           if (rv != APR_FROM_OS_ERROR(WSAEWOULDBLOCK)) {
  @@ -300,8 +301,11 @@
           }
   
           /* wait for the connect to complete or timeout */
  -        FD_ZERO(&fdset);
  -        FD_SET(sock->sock, &fdset);
  +        FD_ZERO(&wfdset);
  +        FD_SET(sock->sock, &wfdset);
  +        FD_ZERO(&efdset);
  +        FD_SET(sock->sock, &efdset);
  +
           if (sock->timeout < 0) {
               tvptr = NULL;
           }
  @@ -310,8 +314,21 @@
               tv.tv_usec = sock->timeout % APR_USEC_PER_SEC;
               tvptr = &tv;
           }
  -        if (select(FD_SETSIZE+1, NULL, &fdset, NULL, tvptr) == SOCKET_ERROR) {
  +        rc = select(FD_SETSIZE+1, NULL, &wfdset, &efdset, tvptr);
  +        if (rc == SOCKET_ERROR) {
               return apr_get_netos_error();
  +        }
  +        else if (!rc) {
  +            return APR_FROM_OS_ERROR(WSAETIMEDOUT);
  +        }
  +        /* Evaluate the efdset */
  +        if (FD_ISSET(sock->sock, &efdset)) {
  +            /* The connect failed. */
  +            unsigned int rclen = sizeof(rc);
  +            if (getsockopt(sock->sock, SOL_SOCKET, SO_ERROR, (char*) &rc, &rclen))
{
  +                return apr_get_netos_error();
  +            }
  +            return APR_FROM_OS_ERROR(rc);
           }
       }
       /* connect was OK .. amazing */
  
  
  

Mime
View raw message