You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by st...@locus.apache.org on 2000/08/31 18:37:40 UTC

cvs commit: apache-1.3/src/main buff.c

stoddard    00/08/31 09:37:38

  Modified:    src      CHANGES
               src/main buff.c
  Log:
  Win32: Work around bug in Win32 select on network reads. Select
  can indicate a socket has data to read, but the subsequent read
  can return WSAEWOULDBLOCK. This problem has been observed
  when running with SSL enabled Apache, specifically, browsers
  sometimes cannot complete the SSL handshake when an SGC
  certificate is used, receiving a network error message.
  
  Submitted by:	Richard Scholz <ri...@subito.de>
  Reviewed by:	Bill Stoddard
  
  Revision  Changes    Path
  1.1570    +8 -0      apache-1.3/src/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/apache-1.3/src/CHANGES,v
  retrieving revision 1.1569
  retrieving revision 1.1570
  diff -u -r1.1569 -r1.1570
  --- CHANGES	2000/08/19 01:52:51	1.1569
  +++ CHANGES	2000/08/31 16:37:34	1.1570
  @@ -1,5 +1,13 @@
   Changes with Apache 1.3.13
   
  +  *) Win32: Work around bug in Win32 select on network reads. Select
  +     can indicate a socket has data to read, but the subsequent read
  +     can return WSAEWOULDBLOCK. This problem has been observed
  +     when running with SSL enabled Apache, specifically, browsers
  +     sometimes cannot complete the SSL handshake when an SGC 
  +     certificate is used, receiving a network error message.
  +     [Richard Scholz richard.scholz@subito.de]
  +
     *) Use "accept filtering" on recent versions of FreeBSD iff the
        kernel is configured to support them. This allows Apache to avoid
        having to handle new connections until the request has arrived.
  
  
  
  1.97      +29 -18    apache-1.3/src/main/buff.c
  
  Index: buff.c
  ===================================================================
  RCS file: /home/cvs/apache-1.3/src/main/buff.c,v
  retrieving revision 1.96
  retrieving revision 1.97
  diff -u -r1.96 -r1.97
  --- buff.c	2000/03/04 20:51:02	1.96
  +++ buff.c	2000/08/31 16:37:37	1.97
  @@ -202,6 +202,7 @@
       struct timeval tv;
       int err = WSAEWOULDBLOCK;
       int rv;
  +    int retry;
   
       if (!(tv.tv_sec = ap_check_alarm()))
   	return (recv(sock, buf, len, flags));
  @@ -214,24 +215,34 @@
       if (rv == SOCKET_ERROR) {
   	err = WSAGetLastError();
   	if (err == WSAEWOULDBLOCK) {
  -	    FD_ZERO(&fdset);
  -	    FD_SET(sock, &fdset);
  -	    tv.tv_usec = 0;
  -	    rv = select(FD_SETSIZE, &fdset, NULL, NULL, &tv);
  -	    if (rv == SOCKET_ERROR)
  -		err = WSAGetLastError();
  -	    else if (rv == 0) {
  -		ioctlsocket(sock, FIONBIO, (u_long*)&iostate);
  -		ap_check_alarm();
  -		WSASetLastError(WSAEWOULDBLOCK);
  -		return (SOCKET_ERROR);
  -	    }
  -	    else {
  -		rv = recv(sock, buf, len, flags);
  -		if (rv == SOCKET_ERROR)
  -		    err = WSAGetLastError();
  -	    }
  -	}
  +            do {
  +                retry = 0;
  +                FD_ZERO(&fdset);
  +                FD_SET(sock, &fdset);
  +                tv.tv_usec = 0;
  +                rv = select(FD_SETSIZE, &fdset, NULL, NULL, &tv);
  +                if (rv == SOCKET_ERROR)
  +                    err = WSAGetLastError();
  +                else if (rv == 0) {
  +                    ioctlsocket(sock, FIONBIO, (u_long*)&iostate);
  +                    ap_check_alarm();
  +                    WSASetLastError(WSAEWOULDBLOCK);
  +                    return (SOCKET_ERROR);
  +                }
  +                else {
  +                    rv = recv(sock, buf, len, flags);
  +                    if (rv == SOCKET_ERROR) {
  +                        err = WSAGetLastError();
  +                        if (err == WSAEWOULDBLOCK) {
  +                            ap_log_error(APLOG_MARK, APLOG_DEBUG, NULL,
  +                                         "select claimed we could read, but in fact we couldn't.");
  +                            retry = 1;
  +                            Sleep(100);
  +                        }
  +                    }
  +                }
  +            } while (retry);
  +        }
       }
   
       ioctlsocket(sock, FIONBIO, (u_long*)&iostate);