httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@hyperreal.org
Subject cvs commit: apache-2.0/src/lib/apr/network_io/win32 networkio.h sockets.c sockopt.c
Date Fri, 08 Oct 1999 21:28:49 GMT
manoj       99/10/08 14:28:48

  Modified:    src/lib/apr/network_io/beos networkio.h sockets.c sockopt.c
               src/lib/apr/network_io/os2 networkio.h sockets.c sockopt.c
               src/lib/apr/network_io/unix sockopt.c
               src/lib/apr/network_io/win32 networkio.h sockets.c sockopt.c
  Log:
  Get rid of the per-connection name lookup on non-Unix platforms. This
  also adds an attempt at correct error handling for gethostbyaddr() for
  all platforms. Non-Unix maintainers should check to make sure this is
  done right.
  
  Revision  Changes    Path
  1.3       +0 -1      apache-2.0/src/lib/apr/network_io/beos/networkio.h
  
  Index: networkio.h
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/network_io/beos/networkio.h,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -d -u -r1.2 -r1.3
  --- networkio.h	1999/10/02 23:11:36	1.2
  +++ networkio.h	1999/10/08 21:27:37	1.3
  @@ -71,7 +71,6 @@
   struct socket_t {
       ap_context_t *cntxt;
       int socketdes;
  -    char *remote_hostname;
       struct sockaddr_in * addr;
       int addr_len;
       int timeout;
  
  
  
  1.6       +0 -10     apache-2.0/src/lib/apr/network_io/beos/sockets.c
  
  Index: sockets.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/network_io/beos/sockets.c,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -d -u -r1.5 -r1.6
  --- sockets.c	1999/10/08 20:04:15	1.5
  +++ sockets.c	1999/10/08 21:27:39	1.6
  @@ -90,7 +90,6 @@
       }
       
       (*new)->socketdes = socket(AF_INET ,SOCK_STREAM, 0);
  -	(*new)->remote_hostname=NULL;
   	(*new)->addr->sin_family = AF_INET; 
       (*new)->addr_len = sizeof(*(*new)->addr);
   	memset(&(*new)->addr->sin_zero, 0, sizeof((*new)->addr->sin_zero));
  @@ -172,8 +171,6 @@
   
   ap_status_t ap_accept(struct socket_t **new, const struct socket_t *sock) 
   { 
  -	struct hostent *hptr;
  -	
   	(*new) = (struct socket_t *)ap_palloc(sock->cntxt,
   	                        sizeof(ap_socket_t)); 
   
  @@ -189,12 +186,6 @@
   		return errno;
   	}
   
  -	hptr = gethostbyaddr((char*)&(*new)->addr->sin_addr, 
  -	                    sizeof(struct in_addr), AF_INET);
  -	if (hptr != NULL){
  -		(*new)->remote_hostname = strdup(hptr->h_name);
  -	}
  -	    
       ap_register_cleanup((*new)->cntxt, (void *)new, 
                           socket_cleanup, NULL);
       return APR_SUCCESS;
  @@ -222,7 +213,6 @@
               return errno; 
       }
        
  -    sock->remote_hostname = strdup(hostname);
       return APR_SUCCESS; 
   } 
   
  
  
  
  1.4       +14 -4     apache-2.0/src/lib/apr/network_io/beos/sockopt.c
  
  Index: sockopt.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/network_io/beos/sockopt.c,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -d -u -r1.3 -r1.4
  --- sockopt.c	1999/10/04 16:37:06	1.3
  +++ sockopt.c	1999/10/08 21:27:41	1.4
  @@ -58,6 +58,7 @@
   #include <sys/socket.h>
   #include <unistd.h>
   #include <fcntl.h>
  +#include <netdb.h>
   #include "networkio.h"
   #include "apr_network_io.h"
   #include "apr_general.h"
  @@ -102,9 +103,18 @@
   
   ap_status_t ap_get_remote_hostname(char **name, struct socket_t *sock)
   {
  -    (*name) = (char*)ap_pstrdup(sock->cntxt, sock->remote_hostname);
  -    if (*name) {
  -        return APR_SUCCESS;
  +    struct hostent *hptr;
  +    
  +    hptr = gethostbyaddr((char *)&(sock->addr->sin_addr), 
  +                         sizeof(struct in_addr), AF_INET);
  +    if (hptr != NULL) {
  +        *name = ap_pstrdup(sock->cntxt, hptr->h_name);
  +        if (*name) {
  +            return APR_SUCCESS;
  +        }
  +        return APR_ENOMEM;
       }
  -    return APR_ENOMEM;
  +
  +    /* XXX - Is this threadsafe? - manoj */
  +    return h_errno;
   }
  
  
  
  1.2       +0 -1      apache-2.0/src/lib/apr/network_io/os2/networkio.h
  
  Index: networkio.h
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/network_io/os2/networkio.h,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -d -u -r1.1 -r1.2
  --- networkio.h	1999/08/17 15:59:43	1.1
  +++ networkio.h	1999/10/08 21:27:52	1.2
  @@ -62,7 +62,6 @@
   struct socket_t {
       ap_context_t *cntxt;
       int socketdes;
  -    char *remote_hostname;
       struct sockaddr_in *addr;
       int addr_len;
   };
  
  
  
  1.3       +0 -10     apache-2.0/src/lib/apr/network_io/os2/sockets.c
  
  Index: sockets.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/network_io/os2/sockets.c,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -d -u -r1.2 -r1.3
  --- sockets.c	1999/10/04 16:37:09	1.2
  +++ sockets.c	1999/10/08 21:27:55	1.3
  @@ -92,7 +92,6 @@
       }
    
       (*new)->socketdes = socket(AF_INET ,SOCK_STREAM, IPPROTO_TCP);
  -    (*new)->remote_hostname = NULL;
   
       (*new)->addr->sin_family = AF_INET;
   
  @@ -147,8 +146,6 @@
   
   ap_status_t ap_accept(struct socket_t **new, const struct socket_t *sock)
   {
  -    struct hostent *hptr;
  -    
       (*new) = (struct socket_t *)ap_palloc(sock->cntxt, 
                               sizeof(struct socket_t));
   
  @@ -164,12 +161,6 @@
           return errno;
       }
       
  -    hptr = gethostbyaddr((char *)&(*new)->addr->sin_addr, 
  -                         sizeof(struct in_addr), AF_INET);
  -    if (hptr != NULL) {
  -        (*new)->remote_hostname = strdup(hptr->h_name);
  -    }
  -    
       ap_register_cleanup((*new)->cntxt, (void *)(*new), 
                           socket_cleanup, NULL);
       return APR_SUCCESS;
  @@ -202,7 +193,6 @@
           return errno;
       }
       else {
  -        sock->remote_hostname = strdup(hostname);
           return APR_SUCCESS;
       }
   }
  
  
  
  1.3       +13 -4     apache-2.0/src/lib/apr/network_io/os2/sockopt.c
  
  Index: sockopt.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/network_io/os2/sockopt.c,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -d -u -r1.2 -r1.3
  --- sockopt.c	1999/10/04 16:37:09	1.2
  +++ sockopt.c	1999/10/08 21:27:58	1.3
  @@ -64,6 +64,7 @@
   #include <netinet/in.h>
   #include <unistd.h>
   #include <fcntl.h>
  +#include <netdb.h>
   
   int soblock(int sd)
   {
  @@ -164,11 +165,19 @@
   
   ap_status_t ap_get_remote_hostname(char **name, struct socket_t *sock)
   {
  -    (*name) = ap_pstrdup(sock->cntxt, sock->remote_hostname);
  -    if (*name) {
  -        return APR_SUCCESS;
  +    struct hostent *hptr;
  +    
  +    hptr = gethostbyaddr((char *)&(sock->addr->sin_addr), 
  +                         sizeof(struct in_addr), AF_INET);
  +    if (hptr != NULL) {
  +        *name = ap_pstrdup(sock->cntxt, hptr->h_name);
  +        if (*name) {
  +            return APR_SUCCESS;
  +        }
  +        return APR_ENOMEM;
       }
  -    return APR_ENOMEM;
  +    /* XXX - Is this threadsafe? - manoj */
  +    return h_errno;
   }
   
   
  
  
  
  1.7       +2 -2      apache-2.0/src/lib/apr/network_io/unix/sockopt.c
  
  Index: sockopt.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/network_io/unix/sockopt.c,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -d -u -r1.6 -r1.7
  --- sockopt.c	1999/10/08 19:44:32	1.6
  +++ sockopt.c	1999/10/08 21:28:24	1.7
  @@ -64,7 +64,6 @@
   #include <netinet/in.h>
   #include <unistd.h>
   #include <fcntl.h>
  -#include <arpa/inet.h>
   #include <netdb.h>
   
   static ap_status_t soblock(int sd)
  @@ -215,7 +214,8 @@
           return APR_ENOMEM;
       }
   
  -    return errno;
  +    /* XXX - Is this threadsafe? */
  +    return h_errno;
   }
   
   
  
  
  
  1.3       +0 -1      apache-2.0/src/lib/apr/network_io/win32/networkio.h
  
  Index: networkio.h
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/network_io/win32/networkio.h,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -d -u -r1.2 -r1.3
  --- networkio.h	1999/09/22 17:30:34	1.2
  +++ networkio.h	1999/10/08 21:28:36	1.3
  @@ -62,7 +62,6 @@
   struct socket_t {
       ap_context_t *cntxt;
       SOCKET sock;
  -    char *remote_hostname;
       struct sockaddr_in *addr;
       size_t addr_len;
       int timeout;
  
  
  
  1.8       +0 -11     apache-2.0/src/lib/apr/network_io/win32/sockets.c
  
  Index: sockets.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/network_io/win32/sockets.c,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -d -u -r1.7 -r1.8
  --- sockets.c	1999/10/08 20:04:24	1.7
  +++ sockets.c	1999/10/08 21:28:38	1.8
  @@ -93,7 +93,6 @@
        * No flags to use when creating a socket, so use 0 for that parameter as well.
        */
       (*new)->sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
  -    (*new)->remote_hostname = NULL;
   
       (*new)->addr->sin_family = AF_INET;
   
  @@ -189,9 +188,6 @@
   
   ap_status_t ap_accept(struct socket_t **new, const struct socket_t *sock)
   {
  -    struct hostent *hptr;
  -    
  -  
       (*new) = (struct socket_t *)ap_palloc(sock->cntxt, 
                               sizeof(struct socket_t));
   
  @@ -207,12 +203,6 @@
           return errno;
       }
       
  -    hptr = gethostbyaddr((char *)&(*new)->addr->sin_addr, 
  -                         sizeof(struct in_addr), AF_INET);
  -    if (hptr != NULL) {
  -        (*new)->remote_hostname = strdup(hptr->h_name);
  -    }
  -    
       ap_register_cleanup((*new)->cntxt, (void *)(*new), 
                           socket_cleanup, NULL);
       return APR_SUCCESS;
  @@ -248,7 +238,6 @@
   
       if (connect(sock->sock, (const struct sockaddr *)sock->addr, 
                   sock->addr_len) == 0) {
  -        sock->remote_hostname = strdup(hostname);
           return APR_SUCCESS;
       }
       else {
  
  
  
  1.3       +19 -4     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.2
  retrieving revision 1.3
  diff -u -d -u -r1.2 -r1.3
  --- sockopt.c	1999/10/04 16:37:16	1.2
  +++ sockopt.c	1999/10/08 21:28:41	1.3
  @@ -136,11 +136,26 @@
   
   ap_status_t ap_get_remote_hostname(char **name, struct socket_t *sock)
   {
  -    (*name) = ap_pstrdup(sock->cntxt, sock->remote_hostname);
  -    if (*name) {
  -        return APR_SUCCESS;
  +    struct hostent *hptr;
  +
  +    hptr = gethostbyaddr((char *)&(sock->addr->sin_addr),
  +                         sizeof(struct in_addr), AF_INET);
  +
  +    if (hptr != NULL) {
  +        *name = ap_pstrdup(sock->cntxt, hptr->h_name);
  +        if (*name) {
  +            return APR_SUCCESS;
  +        }
  +        return APR_ENOMEM;
       }
  -    return APR_ENOMEM;
  +
  +    /* XXX - I don't know what the correct way to deal with host resolution
  +     * errors on Windows is. WSAGetLastError() seems to use a different set of
  +     * error numbers than APR does. The previous code didn't deal with them at
  +     * all.  - manoj
  +     */
  +
  +    return h_errno;
   }
   
   
  
  
  

Mime
View raw message