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 sendrecv.c sockaddr.c sockets.c sockopt.c
Date Mon, 15 Jul 2002 07:26:12 GMT
wrowe       2002/07/15 00:26:12

  Modified:    include/arch/win32 networkio.h
               network_io/win32 sendrecv.c sockaddr.c sockets.c sockopt.c
  Log:
    The right solution.  Follow the herd, use socketdes as our name.
  
  Revision  Changes    Path
  1.28      +1 -4      apr/include/arch/win32/networkio.h
  
  Index: networkio.h
  ===================================================================
  RCS file: /home/cvs/apr/include/arch/win32/networkio.h,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- networkio.h	15 Jul 2002 06:15:00 -0000	1.27
  +++ networkio.h	15 Jul 2002 07:26:12 -0000	1.28
  @@ -58,12 +58,9 @@
   #include "apr_network_io.h"
   #include "apr_general.h"
   
  -// for apr_poll.c;
  -#define socketdes sock
  -
   struct apr_socket_t {
       apr_pool_t         *cntxt;
  -    SOCKET              sock;
  +    SOCKET              socketdes;
       int                 type; /* SOCK_STREAM, SOCK_DGRAM */
       apr_sockaddr_t     *local_addr;
       apr_sockaddr_t     *remote_addr;
  
  
  
  1.56      +11 -11    apr/network_io/win32/sendrecv.c
  
  Index: sendrecv.c
  ===================================================================
  RCS file: /home/cvs/apr/network_io/win32/sendrecv.c,v
  retrieving revision 1.55
  retrieving revision 1.56
  diff -u -r1.55 -r1.56
  --- sendrecv.c	15 Jul 2002 06:34:32 -0000	1.55
  +++ sendrecv.c	15 Jul 2002 07:26:12 -0000	1.56
  @@ -85,9 +85,9 @@
       wsaData.buf = (char*) buf;
   
   #ifndef _WIN32_WCE
  -    rv = WSASend(sock->sock, &wsaData, 1, &dwBytes, 0, NULL, NULL);
  +    rv = WSASend(sock->socketdes, &wsaData, 1, &dwBytes, 0, NULL, NULL);
   #else
  -    rv = send(sock->sock, wsaData.buf, wsaData.len, 0);
  +    rv = send(sock->socketdes, wsaData.buf, wsaData.len, 0);
       dwBytes = rv;
   #endif
       if (rv == SOCKET_ERROR) {
  @@ -114,9 +114,9 @@
       wsaData.buf = (char*) buf;
   
   #ifndef _WIN32_WCE
  -    rv = WSARecv(sock->sock, &wsaData, 1, &dwBytes, &flags, NULL, NULL);
  +    rv = WSARecv(sock->socketdes, &wsaData, 1, &dwBytes, &flags, NULL, NULL);
   #else
  -    rv = recv(sock->sock, wsaData.buf, wsaData.len, 0);
  +    rv = recv(sock->socketdes, wsaData.buf, wsaData.len, 0);
       dwBytes = rv;
   #endif
       if (rv == SOCKET_ERROR) {
  @@ -151,13 +151,13 @@
           pWsaBuf[i].len = vec[i].iov_len;
       }
   #ifndef _WIN32_WCE
  -    rv = WSASend(sock->sock, pWsaBuf, nvec, &dwBytes, 0, NULL, NULL);
  +    rv = WSASend(sock->socketdes, pWsaBuf, nvec, &dwBytes, 0, NULL, NULL);
       if (rv == SOCKET_ERROR) {
           rc = apr_get_netos_error();
       }
   #else
       for (i = 0; i < nvec; i++) {
  -        rv = send(sock->sock, pWsaBuf[i].buf, pWsaBuf[i].len, 0);
  +        rv = send(sock->socketdes, pWsaBuf[i].buf, pWsaBuf[i].len, 0);
           if (rv == SOCKET_ERROR) {
               rc = apr_get_netos_error();
               break;
  @@ -179,7 +179,7 @@
   {
       apr_ssize_t rv;
   
  -    rv = sendto(sock->sock, buf, (*len), flags, 
  +    rv = sendto(sock->socketdes, buf, (*len), flags, 
                   (const struct sockaddr*)&where->sa, 
                   where->salen);
       if (rv == SOCKET_ERROR) {
  @@ -199,7 +199,7 @@
   {
       apr_ssize_t rv;
   
  -    rv = recvfrom(sock->sock, buf, (*len), flags, 
  +    rv = recvfrom(sock->socketdes, buf, (*len), flags, 
                     (struct sockaddr*)&from->sa, &from->salen);
       if (rv == SOCKET_ERROR) {
           (*len) = 0;
  @@ -285,7 +285,7 @@
   #ifdef WAIT_FOR_EVENT
       wait_event = overlapped.hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
   #else
  -    wait_event = (HANDLE) sock->sock;
  +    wait_event = (HANDLE) sock->socketdes;
   #endif
   
       /* Use len to keep track of number of total bytes sent (including headers) */
  @@ -343,7 +343,7 @@
   #if APR_HAS_LARGE_FILES
           overlapped.OffsetHigh = (DWORD)(curoff >> 32);
   #endif
  -        rv = TransmitFile(sock->sock,     /* socket */
  +        rv = TransmitFile(sock->socketdes,  /* socket */
                             file->filehand, /* open file descriptor of the file to be
sent */
                             nbytes,         /* number of bytes to send. 0=send all */
                             0,              /* Number of bytes per send. 0=use default */
  @@ -408,7 +408,7 @@
            */
           if (flags & APR_SENDFILE_DISCONNECT_SOCKET) {
               sock->disconnected = 1;
  -            sock->sock = INVALID_SOCKET;
  +            sock->socketdes = INVALID_SOCKET;
           }
       }
   
  
  
  
  1.29      +1 -1      apr/network_io/win32/sockaddr.c
  
  Index: sockaddr.c
  ===================================================================
  RCS file: /home/cvs/apr/network_io/win32/sockaddr.c,v
  retrieving revision 1.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- sockaddr.c	4 Jun 2002 04:50:44 -0000	1.28
  +++ sockaddr.c	15 Jul 2002 07:26:12 -0000	1.29
  @@ -63,7 +63,7 @@
   static apr_status_t get_local_addr(apr_socket_t *sock)
   {
       sock->local_addr->salen = sizeof(sock->local_addr->sa);
  -    if (getsockname(sock->sock, (struct sockaddr *)&sock->local_addr->sa,
  +    if (getsockname(sock->socketdes, (struct sockaddr *)&sock->local_addr->sa,
                       &sock->local_addr->salen) < 0) {
           return apr_get_netos_error();
       }
  
  
  
  1.83      +21 -21    apr/network_io/win32/sockets.c
  
  Index: sockets.c
  ===================================================================
  RCS file: /home/cvs/apr/network_io/win32/sockets.c,v
  retrieving revision 1.82
  retrieving revision 1.83
  diff -u -r1.82 -r1.83
  --- sockets.c	15 Jul 2002 06:44:16 -0000	1.82
  +++ sockets.c	15 Jul 2002 07:26:12 -0000	1.83
  @@ -66,11 +66,11 @@
   {
       apr_socket_t *thesocket = sock;
   
  -    if (thesocket->sock != INVALID_SOCKET) {
  -        if (closesocket(thesocket->sock) == SOCKET_ERROR) {
  +    if (thesocket->socketdes != INVALID_SOCKET) {
  +        if (closesocket(thesocket->socketdes) == SOCKET_ERROR) {
               return apr_get_netos_error();
           }
  -        thesocket->sock = INVALID_SOCKET;
  +        thesocket->socketdes = INVALID_SOCKET;
       }
       return APR_SUCCESS;
   }
  @@ -118,15 +118,15 @@
       /* For right now, we are not using socket groups.  We may later.
        * No flags to use when creating a socket, so use 0 for that parameter as well.
        */
  -    (*new)->sock = socket(family, type, 0);
  +    (*new)->socketdes = socket(family, type, 0);
   #if APR_HAVE_IPV6
  -    if ((*new)->sock == INVALID_SOCKET && downgrade) {
  +    if ((*new)->socketdes == INVALID_SOCKET && downgrade) {
           family = AF_INET;
  -        (*new)->sock = socket(family, type, 0);
  +        (*new)->socketdes = socket(family, type, 0);
       }
   #endif
   
  -    if ((*new)->sock == INVALID_SOCKET) {
  +    if ((*new)->socketdes == INVALID_SOCKET) {
           return apr_get_netos_error();
       }
       set_socket_vars(*new, family, type);
  @@ -163,7 +163,7 @@
               return APR_BADARG;
       }
   #endif
  -    if (shutdown(thesocket->sock, winhow) == 0) {
  +    if (shutdown(thesocket->socketdes, winhow) == 0) {
           return APR_SUCCESS;
       }
       else {
  @@ -179,7 +179,7 @@
   
   APR_DECLARE(apr_status_t) apr_bind(apr_socket_t *sock, apr_sockaddr_t *sa)
   {
  -    if (bind(sock->sock, 
  +    if (bind(sock->socketdes, 
                (struct sockaddr *)&sa->sa, 
                sa->salen) == -1) {
           return apr_get_netos_error();
  @@ -195,7 +195,7 @@
   
   APR_DECLARE(apr_status_t) apr_listen(apr_socket_t *sock, apr_int32_t backlog)
   {
  -    if (listen(sock->sock, backlog) == SOCKET_ERROR)
  +    if (listen(sock->socketdes, backlog) == SOCKET_ERROR)
           return apr_get_netos_error();
       else
           return APR_SUCCESS;
  @@ -210,7 +210,7 @@
   
       /* Don't allocate the memory until after we call accept. This allows
          us to work with nonblocking sockets. */
  -    s = accept(sock->sock, (struct sockaddr *)&sa, &salen);
  +    s = accept(sock->socketdes, (struct sockaddr *)&sa, &salen);
       if (s == INVALID_SOCKET) {
           return apr_get_netos_error();
       }
  @@ -221,7 +221,7 @@
       (*new)->timeout = -1;   
       (*new)->disconnected = 0;
   
  -    (*new)->sock = s;
  +    (*new)->socketdes = s;
       /* XXX next line looks bogus w.r.t. AF_INET6 support */
       (*new)->remote_addr->salen = sizeof((*new)->remote_addr->sa);
       memcpy (&(*new)->remote_addr->sa, &sa, salen);
  @@ -281,11 +281,11 @@
   {
       apr_status_t rv;
   
  -    if ((sock->sock == INVALID_SOCKET) || (!sock->local_addr)) {
  +    if ((sock->socketdes == INVALID_SOCKET) || (!sock->local_addr)) {
           return APR_ENOTSOCK;
       }
   
  -    if (connect(sock->sock, (const struct sockaddr *)&sa->sa.sin,
  +    if (connect(sock->socketdes, (const struct sockaddr *)&sa->sa.sin,
                   sa->salen) == SOCKET_ERROR) {
           int rc;
           struct timeval tv, *tvptr;
  @@ -307,9 +307,9 @@
   
           /* wait for the connect to complete or timeout */
           FD_ZERO(&wfdset);
  -        FD_SET(sock->sock, &wfdset);
  +        FD_SET(sock->socketdes, &wfdset);
           FD_ZERO(&efdset);
  -        FD_SET(sock->sock, &efdset);
  +        FD_SET(sock->socketdes, &efdset);
   
           if (sock->timeout < 0) {
               tvptr = NULL;
  @@ -328,10 +328,10 @@
               return APR_FROM_OS_ERROR(WSAETIMEDOUT);
           }
           /* Evaluate the efdset */
  -        if (FD_ISSET(sock->sock, &efdset)) {
  +        if (FD_ISSET(sock->socketdes, &efdset)) {
               /* The connect failed. */
               int rclen = sizeof(rc);
  -            if (getsockopt(sock->sock, SOL_SOCKET, SO_ERROR, (char*) &rc, &rclen))
{
  +            if (getsockopt(sock->socketdes, SOL_SOCKET, SO_ERROR, (char*) &rc, &rclen))
{
                   return apr_get_netos_error();
               }
               return APR_FROM_OS_ERROR(rc);
  @@ -369,7 +369,7 @@
   APR_DECLARE(apr_status_t) apr_os_sock_get(apr_os_sock_t *thesock,
                                             apr_socket_t *sock)
   {
  -    *thesock = sock->sock;
  +    *thesock = sock->socketdes;
       return APR_SUCCESS;
   }
   
  @@ -381,7 +381,7 @@
       set_socket_vars(*apr_sock, os_sock_info->family, os_sock_info->type);
       (*apr_sock)->timeout = -1;
       (*apr_sock)->disconnected = 0;
  -    (*apr_sock)->sock = *os_sock_info->os_sock;
  +    (*apr_sock)->socketdes = *os_sock_info->os_sock;
       if (os_sock_info->local) {
           memcpy(&(*apr_sock)->local_addr->sa.sin, 
                  os_sock_info->local, 
  @@ -421,7 +421,7 @@
           (*sock)->disconnected = 0;
       }
       (*sock)->local_port_unknown = (*sock)->local_interface_unknown = 1;
  -    (*sock)->sock = *thesock;
  +    (*sock)->socketdes = *thesock;
       return APR_SUCCESS;
   }
   
  
  
  
  1.41      +28 -21    apr/network_io/win32/sockopt.c
  
  Index: sockopt.c
  ===================================================================
  RCS file: /home/cvs/apr/network_io/win32/sockopt.c,v
  retrieving revision 1.40
  retrieving revision 1.41
  diff -u -r1.40 -r1.41
  --- sockopt.c	15 Jul 2002 06:44:16 -0000	1.40
  +++ sockopt.c	15 Jul 2002 07:26:12 -0000	1.41
  @@ -86,14 +86,14 @@
       if (t == 0) {
           /* Set the socket non-blocking if it was previously blocking */
           if (sock->timeout != 0) {
  -            if ((stat = sononblock(sock->sock)) != APR_SUCCESS)
  +            if ((stat = sononblock(sock->socketdes)) != APR_SUCCESS)
                   return stat;
           }
       }
       else if (t > 0) {
           /* Set the socket to blocking if it was previously non-blocking */
           if (sock->timeout == 0) {
  -            if ((stat = soblock(sock->sock)) != APR_SUCCESS)
  +            if ((stat = soblock(sock->socketdes)) != APR_SUCCESS)
                   return stat;
           }
           /* Reset socket timeouts if the new timeout differs from the old timeout */
  @@ -101,10 +101,10 @@
           {
               /* Win32 timeouts are in msec, represented as int */
               sock->timeout_ms = (int)apr_time_as_msec(t);
  -            setsockopt(sock->sock, SOL_SOCKET, SO_RCVTIMEO, 
  +            setsockopt(sock->socketdes, SOL_SOCKET, SO_RCVTIMEO, 
                          (char *) &sock->timeout_ms, 
                          sizeof(sock->timeout_ms));
  -            setsockopt(sock->sock, SOL_SOCKET, SO_SNDTIMEO, 
  +            setsockopt(sock->socketdes, SOL_SOCKET, SO_SNDTIMEO, 
                          (char *) &sock->timeout_ms, 
                          sizeof(sock->timeout_ms));
           }
  @@ -112,11 +112,11 @@
       else if (t < 0) {
           int zero = 0;
           /* Set the socket to blocking with infinite timeouts */
  -        if ((stat = soblock(sock->sock)) != APR_SUCCESS)
  +        if ((stat = soblock(sock->socketdes)) != APR_SUCCESS)
               return stat;
  -        setsockopt(sock->sock, SOL_SOCKET, SO_RCVTIMEO, 
  +        setsockopt(sock->socketdes, SOL_SOCKET, SO_RCVTIMEO, 
                      (char *) &zero, sizeof(zero));
  -        setsockopt(sock->sock, SOL_SOCKET, SO_SNDTIMEO, 
  +        setsockopt(sock->socketdes, SOL_SOCKET, SO_SNDTIMEO, 
                      (char *) &zero, sizeof(zero));
       }
       sock->timeout = t;
  @@ -139,14 +139,14 @@
           if (on == 0) {
               /* Set the socket non-blocking if it was previously blocking */
               if (sock->timeout != 0) {
  -                if ((stat = sononblock(sock->sock)) != APR_SUCCESS)
  +                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->sock)) != APR_SUCCESS)
  +                if ((stat = soblock(sock->socketdes)) != APR_SUCCESS)
                       return stat;
               }
               /* Reset socket timeouts if the new timeout differs from the old timeout */
  @@ -154,10 +154,10 @@
               {
                   /* Win32 timeouts are in msec */
                   sock->timeout_ms = apr_time_as_msec(on);
  -                setsockopt(sock->sock, SOL_SOCKET, SO_RCVTIMEO, 
  +                setsockopt(sock->socketdes, SOL_SOCKET, SO_RCVTIMEO, 
                              (char *) &sock->timeout_ms, 
                              sizeof(sock->timeout_ms));
  -                setsockopt(sock->sock, SOL_SOCKET, SO_SNDTIMEO, 
  +                setsockopt(sock->socketdes, SOL_SOCKET, SO_SNDTIMEO, 
                              (char *) &sock->timeout_ms, 
                              sizeof(sock->timeout_ms));
               }
  @@ -165,17 +165,20 @@
           else if (on < 0) {
               int zero = 0;
               /* Set the socket to blocking with infinite timeouts */
  -            if ((stat = soblock(sock->sock)) != APR_SUCCESS)
  +            if ((stat = soblock(sock->socketdes)) != APR_SUCCESS)
                   return stat;
  -            setsockopt(sock->sock, SOL_SOCKET, SO_RCVTIMEO, (char *) &zero, sizeof(zero));
  -            setsockopt(sock->sock, SOL_SOCKET, SO_SNDTIMEO, (char *) &zero, sizeof(zero));
  +            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;
       }
       case APR_SO_KEEPALIVE:
           if (on != apr_is_option_set(sock->netmask, APR_SO_KEEPALIVE)) {
  -            if (setsockopt(sock->sock, SOL_SOCKET, SO_KEEPALIVE, (void *)&one, sizeof(int))
== -1) {
  +            if (setsockopt(sock->socketdes, SOL_SOCKET, SO_KEEPALIVE, 
  +                           (void *)&one, sizeof(int)) == -1) {
                   return apr_get_netos_error();
               }
               apr_set_option(&sock->netmask,APR_SO_KEEPALIVE, on);
  @@ -183,7 +186,8 @@
           break;
       case APR_SO_DEBUG:
           if (on != apr_is_option_set(sock->netmask, APR_SO_DEBUG)) {
  -            if (setsockopt(sock->sock, SOL_SOCKET, SO_DEBUG, (void *)&one, sizeof(int))
== -1) {
  +            if (setsockopt(sock->socketdes, SOL_SOCKET, SO_DEBUG, 
  +                           (void *)&one, sizeof(int)) == -1) {
                   return apr_get_netos_error();
               }
               apr_set_option(&sock->netmask, APR_SO_DEBUG, on);
  @@ -191,7 +195,8 @@
           break;
       case APR_SO_REUSEADDR:
           if (on != apr_is_option_set(sock->netmask, APR_SO_REUSEADDR)){
  -            if (setsockopt(sock->sock, SOL_SOCKET, SO_REUSEADDR, (void *)&one, sizeof(int))
== -1) {
  +            if (setsockopt(sock->socketdes, SOL_SOCKET, SO_REUSEADDR, 
  +                           (void *)&one, sizeof(int)) == -1) {
                   return apr_get_netos_error();
               }
               apr_set_option(&sock->netmask, APR_SO_REUSEADDR, on);
  @@ -200,11 +205,11 @@
       case APR_SO_NONBLOCK:
           if (apr_is_option_set(sock->netmask, APR_SO_NONBLOCK) != on){
               if (on) {
  -                if ((stat = sononblock(sock->sock)) != APR_SUCCESS) 
  +                if ((stat = sononblock(sock->socketdes)) != APR_SUCCESS) 
                       return stat;
               }
               else {
  -                if ((stat = soblock(sock->sock)) != APR_SUCCESS)
  +                if ((stat = soblock(sock->socketdes)) != APR_SUCCESS)
                       return stat;
               }
               apr_set_option(&sock->netmask, APR_SO_NONBLOCK, on);
  @@ -216,7 +221,8 @@
               struct linger li;
               li.l_onoff = on;
               li.l_linger = MAX_SECS_TO_LINGER;
  -            if (setsockopt(sock->sock, SOL_SOCKET, SO_LINGER, (char *) &li, sizeof(struct
linger)) == -1) {
  +            if (setsockopt(sock->socketdes, SOL_SOCKET, SO_LINGER, 
  +                           (char *) &li, sizeof(struct linger)) == -1) {
                   return apr_get_netos_error();
               }
               apr_set_option(&sock->netmask, APR_SO_LINGER, on);
  @@ -225,7 +231,8 @@
       }
       case APR_TCP_NODELAY:
           if (apr_is_option_set(sock->netmask, APR_TCP_NODELAY) != on){
  -            if (setsockopt(sock->sock, IPPROTO_TCP, TCP_NODELAY, (void *)&on, sizeof(int))
== -1) {
  +            if (setsockopt(sock->socketdes, IPPROTO_TCP, TCP_NODELAY, 
  +                           (void *)&on, sizeof(int)) == -1) {
                   return apr_get_netos_error();
               }
               apr_set_option(&sock->netmask, APR_TCP_NODELAY, on);
  
  
  

Mime
View raw message