Hi,

sadly apr_socket_close() does *always* unlink the bound AF_UNIX file, so
to make Listen work again with a unix domain socket, this fix helps to
make it work again, by closing the old listeners first, and then binding
again.

httpd.conf:
Listen /usr/local/apache2/httpd.sock:80

Not sure why it is done in the reverese order currently, it probably has
a reason I don't understand yet...

But closing first and then binding again, the unix domain socket file
will be bound by the second open_listeners call and not unlinked as in
the current code:

curl --unix-socket /usr/local/apache2/httpd.sock -v "http://localhost:8080/";

diff --git a/server/listen.c b/server/listen.c
index cee11943b2..c85cb250e8 100644
--- a/server/listen.c
+++ b/server/listen.c
@@ -584,6 +584,10 @@ static int open_listeners(apr_pool_t *pool)
     int use_nonblock;
 #endif
 
+    /* close the old listeners */
+    ap_close_listeners_ex(old_listeners);
+    old_listeners = NULL;
+
     /* Don't allocate a default listener.  If we need to listen to a
      * port, then the user needs to have a Listen directive in their
      * config file.
@@ -697,10 +701,6 @@ static int open_listeners(apr_pool_t *pool)
         }
     }
 
-    /* close the old listeners */
-    ap_close_listeners_ex(old_listeners);
-    old_listeners = NULL;
-
 #if AP_NONBLOCK_WHEN_MULTI_LISTEN
     /* if multiple listening sockets, make them non-blocking so that
      * if select()/poll() reports readability for a reset connection that


Which only leaves one problem: mod_cgid

This module does fork and in the child calls
ap_close_listeners which unlinks the AF_UNIX file again :-(

diff --git a/modules/generators/mod_cgid.c b/modules/generators/mod_cgid.c
index b27dd802d8..72c4965f5b 100644
--- a/modules/generators/mod_cgid.c
+++ b/modules/generators/mod_cgid.c
@@ -730,7 +730,9 @@ static int cgid_server(void *data)
     apr_signal(SIGHUP, daemon_signal_handler);
 
     /* Close our copy of the listening sockets */
-    ap_close_listeners();
+
+    /* sadly this will unlink the AF_UNIX socket file :-( */
+    /* ap_close_listeners(); */
 
     /* cgid should use its own suexec doer */
     ap_hook_get_suexec_identity(cgid_suexec_id_doer, NULL, NULL,

I think apr_socket_close should:
1.) either not unlink uncondtionally AF_UNIX file, which problaby breaks
existing users if changed
2.) or provide a apr_socket_close_ex function which has an flag to control 
unlinking
of file

What do you think, opinions?

Mfg
Thomas

PS: Is Apache Bugzilla down currently?

Reply via email to