You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by ak...@apache.org on 2004/03/01 16:55:54 UTC

cvs commit: apr/include apr.hw

ake         2004/03/01 07:55:54

  Modified:    server/mpm/winnt child.c mpm_winnt.h
               include  apr.hw
  Log:
  enable IPv6 for Windows XP and 2003. In addition this this
  we need a way to set APR_HAVE_IPV6 at build time in apr.hw
  
  Revision  Changes    Path
  1.32      +49 -7     httpd-2.0/server/mpm/winnt/child.c
  
  Index: child.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/server/mpm/winnt/child.c,v
  retrieving revision 1.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- child.c	29 Feb 2004 16:19:18 -0000	1.31
  +++ child.c	1 Mar 2004 15:55:54 -0000	1.32
  @@ -319,13 +319,17 @@
       int wait_time = 1;
       int csd;
       SOCKET nsd = INVALID_SOCKET;
  -    struct sockaddr_in sa_client;
       int count_select_errors = 0;
       int rc;
       int clen;
       ap_listen_rec *lr;
       struct fd_set listenfds;
       SOCKET listenmaxfd = INVALID_SOCKET;
  +#if APR_HAVE_IPV6
  +    struct sockaddr_in6 sa_client;
  +#else
  +    struct sockaddr_in sa_client;
  +#endif
   
       /* Setup the listeners 
        * ToDo: Use apr_poll()
  @@ -402,7 +406,13 @@
   static PCOMP_CONTEXT win9x_get_connection(PCOMP_CONTEXT context)
   {
       apr_os_sock_info_t sockinfo;
  -    int len;
  +    int len, salen;
  +#if APR_HAVE_IPV6
  +    salen = sizeof(struct sockaddr_in6);
  +#else
  +    salen = sizeof(struct sockaddr_in);
  +#endif
  +
   
       if (context == NULL) {
           /* allocate the completion context and the transaction pool */
  @@ -422,7 +432,7 @@
           if (context->accept_socket == INVALID_SOCKET) {
               return NULL;
           }
  -	len = sizeof(struct sockaddr);
  +        len = salen;
           context->sa_server = apr_palloc(context->ptrans, len);
           if (getsockname(context->accept_socket, 
                           context->sa_server, &len)== SOCKET_ERROR) {
  @@ -430,7 +440,7 @@
                            "getsockname failed");
               continue;
           }
  -        len = sizeof(struct sockaddr);
  +        len = salen;
           context->sa_client = apr_palloc(context->ptrans, len);
           if ((getpeername(context->accept_socket,
                            context->sa_client, &len)) == SOCKET_ERROR) {
  @@ -441,7 +451,7 @@
           sockinfo.os_sock = &context->accept_socket;
           sockinfo.local   = context->sa_server;
           sockinfo.remote  = context->sa_client;
  -        sockinfo.family  = APR_INET;
  +        sockinfo.family  = context->sa_server->sa_family;
           sockinfo.type    = SOCK_STREAM;
           apr_os_sock_make(&context->sock, &sockinfo, context->ptrans);
   
  @@ -473,8 +483,21 @@
       DWORD BytesRead;
       SOCKET nlsd;
       int rv, err_count = 0;
  +#if APR_HAVE_IPV6
  +    SOCKADDR_STORAGE ss_listen;
  +    int namelen = sizeof(ss_listen);
  +#endif
   
       apr_os_sock_get(&nlsd, lr->sd);
  +
  +#if APR_HAVE_IPV6
  +    if (getsockname(nlsd, (struct sockaddr *)&ss_listen, &namelen) == SOCKET_ERROR) { 
  +        ap_log_error(APLOG_MARK,APLOG_ERR, apr_get_netos_error(), ap_server_conf,
  +                    "winnt_accept: getsockname error on listening socket, is IPv6 available?");
  +        return;
  +   }
  +#endif
  +
       ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, ap_server_conf,
                    "Child %d: Starting thread to listen on port %d.", my_pid, lr->bind_addr->port);
       while (!shutdown_in_progress) {
  @@ -488,6 +511,25 @@
           }
   
           /* Create and initialize the accept socket */
  +#if APR_HAVE_IPV6
  +        if (context->accept_socket == INVALID_SOCKET) {
  +            context->accept_socket = socket(ss_listen.ss_family, SOCK_STREAM, IPPROTO_TCP);
  +            context->socket_family = ss_listen.ss_family;
  +        }
  +        else if (context->socket_family != ss_listen.ss_family) { 
  +            closesocket(context->accept_socket);
  +            context->accept_socket = socket(ss_listen.ss_family, SOCK_STREAM, IPPROTO_TCP);
  +            context->socket_family = ss_listen.ss_family;
  +        }
  +
  +        if (context->accept_socket == INVALID_SOCKET) {
  +            ap_log_error(APLOG_MARK,APLOG_WARNING, apr_get_netos_error(), ap_server_conf,
  +                         "winnt_accept: Failed to allocate an accept socket. "
  +                         "Temporary resource constraint? Try again.");
  +            Sleep(100);
  +            continue;
  +        }
  +#else
           if (context->accept_socket == INVALID_SOCKET) {
               context->accept_socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
               if (context->accept_socket == INVALID_SOCKET) {
  @@ -499,7 +541,7 @@
                   continue;
               }
           }
  -
  +#endif
           /* AcceptEx on the completion context. The completion context will be 
            * signaled when a connection is accepted. 
            */
  @@ -606,7 +648,7 @@
           sockinfo.os_sock = &context->accept_socket;
           sockinfo.local   = context->sa_server;
           sockinfo.remote  = context->sa_client;
  -        sockinfo.family  = APR_INET;
  +        sockinfo.family  = context->sa_server->sa_family;
           sockinfo.type    = SOCK_STREAM;
           apr_os_sock_make(&context->sock, &sockinfo, context->ptrans);
   
  
  
  
  1.49      +6 -0      httpd-2.0/server/mpm/winnt/mpm_winnt.h
  
  Index: mpm_winnt.h
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/server/mpm/winnt/mpm_winnt.h,v
  retrieving revision 1.48
  retrieving revision 1.49
  diff -u -r1.48 -r1.49
  --- mpm_winnt.h	9 Feb 2004 20:40:51 -0000	1.48
  +++ mpm_winnt.h	1 Mar 2004 15:55:54 -0000	1.49
  @@ -85,7 +85,12 @@
   #define CONTAINING_RECORD(address, type, field) ((type *)( \
                                                     (PCHAR)(address) - \
                                                     (PCHAR)(&((type *)0)->field)))
  +#if APR_HAVE_IPV6
  +#define PADDED_ADDR_SIZE sizeof(SOCKADDR_IN6)+16
  +#else
   #define PADDED_ADDR_SIZE sizeof(SOCKADDR_IN)+16
  +#endif
  +
   typedef struct CompContext {
       struct CompContext *next;
       OVERLAPPED Overlapped;
  @@ -98,6 +103,7 @@
       int sa_client_len;
       apr_pool_t *ptrans;
       apr_bucket_alloc_t *ba;
  +    short socket_family;
   } COMP_CONTEXT, *PCOMP_CONTEXT;
   
   typedef enum {
  
  
  
  1.123     +2 -1      apr/include/apr.hw
  
  Index: apr.hw
  ===================================================================
  RCS file: /home/cvs/apr/include/apr.hw,v
  retrieving revision 1.122
  retrieving revision 1.123
  diff -u -r1.122 -r1.123
  --- apr.hw	28 Feb 2004 18:31:41 -0000	1.122
  +++ apr.hw	1 Mar 2004 15:55:54 -0000	1.123
  @@ -48,11 +48,12 @@
    *   C4075: slight indirection changes (unsigned short* vs short[])
    *   C4100: unreferenced formal parameter
    *   C4127: conditional expression is constant
  + *   C4163: '_rotl64' : not available as an intrinsic function
    *   C4201: nonstandard extension nameless struct/unions
    *   C4244: int to char/short - precision loss
    *   C4514: unreferenced inline function removed
    */
  -#pragma warning(disable: 4100 4127 4201 4514; once: 4057 4075 4244)
  +#pragma warning(disable: 4100 4127 4163 4201 4514; once: 4057 4075 4244)
   
   /* Has windows.h already been included?  If so, our preferences don't matter,
    * but we will still need the winsock things no matter what was included.