apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wr...@apache.org
Subject cvs commit: apr/network_io/win32 sockopt.c
Date Mon, 15 Jul 2002 20:29:38 GMT
wrowe       2002/07/15 13:29:38

  Modified:    network_io/os2 sockopt.c
               network_io/unix sockopt.c
               network_io/win32 sockopt.c
  Log:
    As rbb pointed out, two constructors are prone to bugs.  Remap our old
    apr_socket_opt_set(SO_TIMEOUT) flavor to invoke apr_socket_timeout_set()
  
  Revision  Changes    Path
  1.29      +2 -2      apr/network_io/os2/sockopt.c
  
  Index: sockopt.c
  ===================================================================
  RCS file: /home/cvs/apr/network_io/os2/sockopt.c,v
  retrieving revision 1.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- sockopt.c	15 Jul 2002 07:39:32 -0000	1.28
  +++ sockopt.c	15 Jul 2002 20:29:38 -0000	1.29
  @@ -122,7 +122,7 @@
       }
       if (opt & APR_SO_TIMEOUT) {
           /* XXX: To be deprecated */
  -        sock->timeout = on;
  +        return apr_socket_timeout_set(sock, on);
       }
       if (opt & APR_TCP_NODELAY) {
           if (setsockopt(sock->socketdes, IPPROTO_TCP, TCP_NODELAY, (void *)&on, sizeof(int))
== -1) {
  @@ -147,7 +147,7 @@
       switch(opt) {
       case APR_SO_TIMEOUT:
           /* XXX: To be deprecated */
  -        *on = sock->timeout;
  +        *on = (apr_int32_t)sock->timeout;
           break;
       default:
           return APR_EINVAL;
  
  
  
  1.59      +2 -29     apr/network_io/unix/sockopt.c
  
  Index: sockopt.c
  ===================================================================
  RCS file: /home/cvs/apr/network_io/unix/sockopt.c,v
  retrieving revision 1.58
  retrieving revision 1.59
  diff -u -r1.58 -r1.59
  --- sockopt.c	15 Jul 2002 07:39:32 -0000	1.58
  +++ sockopt.c	15 Jul 2002 20:29:38 -0000	1.59
  @@ -227,34 +227,7 @@
       }
       if (opt & APR_SO_TIMEOUT) { 
           /* XXX: To be deprecated */
  -        /* If our timeout is positive or zero and our last timeout was
  -         * negative, then we need to ensure that we are non-blocking.
  -         * Conversely, if our timeout is negative and we had a positive
  -         * or zero timeout, we must make sure our socket is blocking.
  -         * We want to avoid calling fcntl more than necessary on the socket,
  -         */
  -        if (on >= 0 && sock->timeout < 0){
  -            if (apr_is_option_set(sock->netmask, APR_SO_NONBLOCK) != 1){
  -                if ((rv = sononblock(sock->socketdes)) != APR_SUCCESS){
  -                    return rv;
  -                }
  -            }
  -        } 
  -        else if (on < 0 && sock->timeout >= 0){
  -            if (apr_is_option_set(sock->netmask, APR_SO_NONBLOCK) != 0){ 
  -                if ((rv = soblock(sock->socketdes)) != APR_SUCCESS) { 
  -                    return rv; 
  -                }
  -            } 
  -        }
  -        /* must disable the incomplete read support if we change to a
  -         * blocking socket.
  -         */
  -        if (on == 0) {
  -            sock->netmask &= ~APR_INCOMPLETE_READ;
  -        }
  -        sock->timeout = on; 
  -        apr_set_option(&sock->netmask, APR_SO_TIMEOUT, on);
  +        return apr_socket_timeout_set(sock, on);
       } 
       if (opt & APR_TCP_NODELAY) {
   #if defined(TCP_NODELAY)
  @@ -337,7 +310,7 @@
       switch(opt) {
           case APR_SO_TIMEOUT:
               /* XXX: To be deprecated */
  -            *on = sock->timeout;
  +            *on = (apr_int32_t)sock->timeout;
               break;
           default:
               *on = apr_is_option_set(sock->netmask, opt);
  
  
  
  1.45      +2 -39     apr/network_io/win32/sockopt.c
  
  Index: sockopt.c
  ===================================================================
  RCS file: /home/cvs/apr/network_io/win32/sockopt.c,v
  retrieving revision 1.44
  retrieving revision 1.45
  diff -u -r1.44 -r1.45
  --- sockopt.c	15 Jul 2002 08:22:35 -0000	1.44
  +++ sockopt.c	15 Jul 2002 20:29:38 -0000	1.45
  @@ -135,45 +135,8 @@
       switch (opt) {
       case APR_SO_TIMEOUT: 
       {
  -        /* XXX: to be deprecated */
  -        if (on == 0) {
  -            /* Set the socket non-blocking if it was previously blocking */
  -            if (sock->timeout != 0) {
  -                if ((stat = sononblock(sock->socketdes)) != APR_SUCCESS)
  -                    return stat;
  -            }
  -        }
  -        else if (on > 0) {
  -            /* Set the socket to blocking if it was previously non-blocking */
  -            if (sock->timeout == 0) {
  -                if ((stat = soblock(sock->socketdes)) != APR_SUCCESS)
  -                    return stat;
  -            }
  -            /* Reset socket timeouts if the new timeout differs from the old timeout */
  -            if (sock->timeout != on) 
  -            {
  -                /* Win32 timeouts are in msec */
  -                sock->timeout_ms = apr_time_as_msec(on);
  -                setsockopt(sock->socketdes, SOL_SOCKET, SO_RCVTIMEO, 
  -                           (char *) &sock->timeout_ms, 
  -                           sizeof(sock->timeout_ms));
  -                setsockopt(sock->socketdes, SOL_SOCKET, SO_SNDTIMEO, 
  -                           (char *) &sock->timeout_ms, 
  -                           sizeof(sock->timeout_ms));
  -            }
  -        }
  -        else if (on < 0) {
  -            int zero = 0;
  -            /* Set the socket to blocking with infinite timeouts */
  -            if ((stat = soblock(sock->socketdes)) != APR_SUCCESS)
  -                return stat;
  -            setsockopt(sock->socketdes, SOL_SOCKET, SO_RCVTIMEO, 
  -                       (char *) &zero, sizeof(zero));
  -            setsockopt(sock->socketdes, SOL_SOCKET, SO_SNDTIMEO, 
  -                       (char *) &zero, sizeof(zero));
  -        }
  -        sock->timeout = on;
  -        break;
  +        /* XXX: To be deprecated */
  +        return apr_socket_timeout_set(sock, on);
       }
       case APR_SO_KEEPALIVE:
           if (on != apr_is_option_set(sock->netmask, APR_SO_KEEPALIVE)) {
  
  
  

Mime
View raw message