+ /* 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_socket_opt_set(s, APR_SO_REUSEADDR, one);
+ if (stat != APR_SUCCESS && stat != APR_ENOTIMPL) {
+ ap_log_perror(APLOG_MARK, APLOG_CRIT, stat, p, APLOGNO(00074)
+ "make_sock: for address %pI, apr_socket_opt_set: (SO_REUSEADDR)",
+ server->bind_addr);
+ apr_socket_close(s);
+ return stat;
+@@ -260,40 +269,159 @@
+ ap_log_perror(APLOG_MARK, APLOG_WARNING, rv, p, APLOGNO(00075)
+ "Failed to enable the '%s' Accept Filter",
+ accf);
+ }
+ #else
+ rv = apr_socket_opt_set(s, APR_TCP_DEFER_ACCEPT, 30);
+ if (rv != APR_SUCCESS && !APR_STATUS_IS_ENOTIMPL(rv)) {
+ ap_log_perror(APLOG_MARK, APLOG_WARNING, rv, p, APLOGNO(00076)
+ "Failed to enable APR_TCP_DEFER_ACCEPT");
+ }
+ #endif
+ }
+ }
+
+ static apr_status_t close_listeners_on_exec(void *v)
+ {
+ ap_close_listeners();