httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wr...@apache.org
Subject cvs commit: httpd-2.0/server listen.c
Date Thu, 14 Mar 2002 04:06:03 GMT
wrowe       02/03/13 20:06:03

  Modified:    server   listen.c
  Log:
    Our ap_listeners were binding to IIS sockets, other Apache instances'
    listeners, the bottoms of peoples' shoes, etc.
  
    Wait to set SO_REUSEADDR on Win32 until the parent is certain the
    port is all ours.
  
  Revision  Changes    Path
  1.76      +23 -0     httpd-2.0/server/listen.c
  
  Index: listen.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/server/listen.c,v
  retrieving revision 1.75
  retrieving revision 1.76
  diff -u -r1.75 -r1.76
  --- listen.c	13 Mar 2002 20:48:00 -0000	1.75
  +++ listen.c	14 Mar 2002 04:06:02 -0000	1.76
  @@ -91,6 +91,7 @@
       int one = 1;
       apr_status_t stat;
   
  +#ifndef WIN32
       stat = apr_setsocketopt(s, APR_SO_REUSEADDR, one);
       if (stat != APR_SUCCESS && stat != APR_ENOTIMPL) {
           ap_log_perror(APLOG_MARK, APLOG_CRIT, stat, p,
  @@ -99,6 +100,7 @@
           apr_socket_close(s);
           return stat;
       }
  +#endif
   
       stat = apr_setsocketopt(s, APR_SO_KEEPALIVE, one);
       if (stat != APR_SUCCESS && stat != APR_ENOTIMPL) {
  @@ -159,6 +161,27 @@
           apr_socket_close(s);
           return stat;
       }
  +
  +#ifdef WIN32
  +    /* I seriously doubt that this would work on Unix; I have doubts that
  +     * it entirely solves the problem on Win32.  However, since setting
  +     * reuseaddr on the listener -prior- to binding the socket has allowed
  +     * us to attach to the same port as an already running instance of
  +     * Apache, or even another web server, we cannot identify that this
  +     * port was exclusively granted to this instance of Apache.
  +     *
  +     * So set reuseaddr, but do not attempt to do so until we have the
  +     * parent listeners successfully bound.
  +     */
  +    stat = apr_setsocketopt(s, APR_SO_REUSEADDR, one);
  +    if (stat != APR_SUCCESS && stat != APR_ENOTIMPL) {
  +        ap_log_perror(APLOG_MARK, APLOG_CRIT, stat, p,
  +                    "make_sock: for address %pI, setsockopt: (SO_REUSEADDR)", 
  +                     server->bind_addr);
  +        apr_socket_close(s);
  +        return stat;
  +    }
  +#endif
   
   #if APR_HAS_SO_ACCEPTFILTER
   #ifndef ACCEPT_FILTER_NAME
  
  
  

Mime
View raw message