In #apache on FreeNode IRC, mod_unique_id is one of the most common
problems.  Thanks to some distributions (ahem. gentoo.), that commonly
do not configure DNS correctly, and enable mod_unique_id by default,
several times a day people come in saying apache will not start for
them.

I see three ways to solve this issue:
1) Make the error we spit out more verbose when DNS is broken.
2) Continue running, turning off mod_unique_id.
3) Complain to upstream vendors.(don't enable mod_unique_id by default!)

Most of the people with this problem have no reason to be running
mod_unique_id, but their distro has enabled it, so I believe the best
method is to spit out info about it in the error log, but to keep Apache
running.

The attached patch is a quick hack to let mod_unique_id disable itself
if the DNS resolution fails.  

No matter what is done, It would be nice to have some sort of change
into 2.0.50 before a release is made.

Thanks,

-Paul Querna
Index: mod_unique_id.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/modules/metadata/mod_unique_id.c,v
retrieving revision 1.50
diff -u -r1.50 mod_unique_id.c
--- mod_unique_id.c	9 Feb 2004 20:29:21 -0000	1.50
+++ mod_unique_id.c	16 Jun 2004 01:58:37 -0000
@@ -115,6 +115,8 @@
  * htonl/ntohl. Well, this shouldn't be a problem till year 2106.
  */
 
+static int mod_unique_id_enabled;
+
 static unsigned global_in_addr;
 
 static unique_id_rec cur_unique_id;
@@ -165,8 +167,9 @@
      */
     if ((rv = apr_gethostname(str, sizeof(str) - 1, p)) != APR_SUCCESS) {
         ap_log_error(APLOG_MARK, APLOG_ALERT, rv, main_server,
-          "mod_unique_id: unable to find hostname of the server");
-        return HTTP_INTERNAL_SERVER_ERROR;
+          "mod_unique_id: unable to find hostname of the server. mod_unique_id is now disabled.");
+        mod_unique_id_enabled = 0;
+        return OK;
     }
 
     if ((rv = apr_sockaddr_info_get(&sockaddr, str, AF_INET, 0, 0, p)) == APR_SUCCESS) {
@@ -184,9 +187,13 @@
                          "mod_unique_id: using low-order bits of IPv6 address "
                          "as if they were unique");
         }
-        else
+        else {
+#endif
+        mod_unique_id_enabled = 0;
+        return OK;
+#if APR_HAVE_IPV6
+        }
 #endif
-        return HTTP_INTERNAL_SERVER_ERROR;
     }
 
     apr_sockaddr_ip_get(&ipaddrstr, sockaddr);
@@ -208,6 +215,7 @@
      * next second.
      */
     apr_sleep(apr_time_from_sec(1) - apr_time_usec(apr_time_now()));
+    mod_unique_id_enabled = 1;
     return OK;
 }
 
@@ -216,6 +224,8 @@
     pid_t pid;
     apr_time_t tv;
 
+    if(mod_unique_id_enabled == 0)
+        return;
     /*
      * Note that we use the pid because it's possible that on the same
      * physical machine there are multiple servers (i.e. using Listen). But
@@ -290,6 +300,10 @@
     unsigned short counter;
     const char *e;
     int i,j,k;
+
+    if(mod_unique_id_enabled == 0) {
+        return DECLINED;
+    }
 
     /* copy the unique_id if this is an internal redirect (we're never
      * actually called for sub requests, so we don't need to test for

Reply via email to