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/17 22:26:30 UTC

cvs commit: apache-2.0/src/lib/apr/network_io/win32 sockopt.c

stoddard    00/08/17 13:26:30

  Modified:    src/lib/apr/network_io/win32 sockopt.c
  Log:
  Win32: Simplify the code a bit by eliminating a variable.
  
  Revision  Changes    Path
  1.24      +10 -14    apache-2.0/src/lib/apr/network_io/win32/sockopt.c
  
  Index: sockopt.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/network_io/win32/sockopt.c,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- sockopt.c	2000/08/04 02:42:32	1.23
  +++ sockopt.c	2000/08/17 20:26:29	1.24
  @@ -88,34 +88,30 @@
       switch (opt) {
       case APR_SO_TIMEOUT: 
       {
  -        int new_timeout;
  -        if (on <= 0)
  -            new_timeout = on;
  -        else
  -            /* Convert from APR units (microseconds) to windows units 
  -             * (milliseconds) */
  -            new_timeout = on/1000;
  +        if (on > 0) {
  +            on = on/1000;  /* Convert from APR units (uS) to windows units (mS) */ 
  +        }
   
  -        if (new_timeout == 0) {
  +        if (on == 0) {
               /* Set the socket non-blocking if it was previously blocking */
               if (sock->timeout != 0) {
                   if ((stat = sononblock(sock->sock)) != APR_SUCCESS)
                       return stat;
               }
           }
  -        else if (new_timeout > 0) {
  +        else if (on > 0) {
               /* Set the socket to blocking if it was previously non-blocking */
               if (sock->timeout == 0) {
                   if ((stat = soblock(sock->sock)) != APR_SUCCESS)
                       return stat;
               }
               /* Reset socket timeouts if the new timeout differs from the old timeout */
  -            if (sock->timeout != new_timeout) {
  -                setsockopt(sock->sock, SOL_SOCKET, SO_RCVTIMEO, (char *) &new_timeout, sizeof(new_timeout));
  -                setsockopt(sock->sock, SOL_SOCKET, SO_SNDTIMEO, (char *) &new_timeout, sizeof(new_timeout));
  +            if (sock->timeout != on) {
  +                setsockopt(sock->sock, SOL_SOCKET, SO_RCVTIMEO, (char *) &on, sizeof(on));
  +                setsockopt(sock->sock, SOL_SOCKET, SO_SNDTIMEO, (char *) &on, sizeof(on));
               }
           }
  -        else if (new_timeout < 0) {
  +        else if (on < 0) {
               int zero = 0;
               /* Set the socket to blocking with infinite timeouts */
               if ((stat = soblock(sock->sock)) != APR_SUCCESS)
  @@ -123,7 +119,7 @@
               setsockopt(sock->sock, SOL_SOCKET, SO_RCVTIMEO, (char *) &zero, sizeof(zero));
               setsockopt(sock->sock, SOL_SOCKET, SO_SNDTIMEO, (char *) &zero, sizeof(zero));
           }
  -        sock->timeout = new_timeout;
  +        sock->timeout = on;
           break;
       }
       case APR_SO_KEEPALIVE: