httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jon Travis <jtra...@covalent.net>
Subject [PATCH] inet_ntoa thread safeness cleanup
Date Sat, 02 Dec 2000 00:32:20 GMT
inet_ntoa is generally not threadsafe.  This patch cleans up a few files
which use it.  It is worth noting that the proxy module uses inet_ntoa all
over the place, but since this is in a big rehashment right now, I didn't
touch it.  I imagine a lot of this will become obsolete as we get more
IPV6 friendly, but this fixes it for now.

(This patch is dependent on a patch I just gave to the APR team to be 
committed first, for some #define-fu)

Commit or reject at your leisure,

-- Jon


Index: main/http_vhost.c
===================================================================
RCS file: /home/cvspublic/apache-2.0/src/main/http_vhost.c,v
retrieving revision 1.40
diff -u -r1.40 http_vhost.c
--- main/http_vhost.c	2000/11/21 19:10:18	1.40
+++ main/http_vhost.c	2000/12/02 00:12:10
@@ -640,13 +640,16 @@
 		    s->server_hostname = apr_pstrdup(p, (char *) h->h_name);
 		}
 		else {
+		    char ntoabuf[APR_IPV4_DOTDEC_LEN];
 		    /* again, what can we do?  They didn't specify a
 		       ServerName, and their DNS isn't working. -djg */
+
+		    apr_inet_ntop(APR_INET, s->addrs->host_addr, ntoabuf,
+				  sizeof(ntoabuf));
 		    ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, main_s,
 			    "Failed to resolve server name "
 			    "for %s (check DNS) -- or specify an explicit "
-			    "ServerName",
-			    inet_ntoa(s->addrs->host_addr));
+			    "ServerName", ntoabuf);
 		    s->server_hostname =
 			apr_pstrdup(p, "bogus_host_without_reverse_dns");
 		}
Index: modules/standard/mod_unique_id.c
===================================================================
RCS file: /home/cvspublic/apache-2.0/src/modules/standard/mod_unique_id.c,v
retrieving revision 1.19
diff -u -r1.19 mod_unique_id.c
--- modules/standard/mod_unique_id.c	2000/10/16 06:05:07	1.19
+++ modules/standard/mod_unique_id.c	2000/12/02 00:12:14
@@ -181,10 +181,10 @@
 #ifndef MAXHOSTNAMELEN
 #define MAXHOSTNAMELEN 256
 #endif
-    char str[MAXHOSTNAMELEN + 1];
+    char str[MAXHOSTNAMELEN + 1], ntoabuf[APR_IPV4_DOTDEC_LEN];
     struct hostent *hent;
     apr_interval_time_t pause;
-
+    
     /*
      * Calculate the sizes and offsets in cur_unique_id.
      */
@@ -227,10 +227,11 @@
 
     global_in_addr = ((struct in_addr *) hent->h_addr_list[0])->s_addr;
 
+    apr_inet_ntop(APR_INET, *(struct in_addr *) hent->h_addr_list[0],
+		  ntoabuf, sizeof(ntoabuf));
     ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_INFO, 0, main_server,
-                "mod_unique_id: using ip addr %s",
-                inet_ntoa(*(struct in_addr *) hent->h_addr_list[0]));
-
+		 "mod_unique_id: using ip addr %s", ntoabuf);
+		 
     /*
      * If the server is pummelled with restart requests we could possibly end
      * up in a situation where we're starting again during the same second

Mime
View raw message