Index: lib/hostip.c
===================================================================
RCS file: /repository/curl/lib/hostip.c,v
retrieving revision 1.111
diff -u -r1.111 hostip.c
--- lib/hostip.c	15 Dec 2003 15:22:10 -0000	1.111
+++ lib/hostip.c	15 Dec 2003 16:05:38 -0000
@@ -195,6 +195,23 @@
                                  hostcache_timestamp_remove);
 }
 
+void Curl_hostcache_prune(struct SessionHandle *data)
+{
+  time_t now;
+  if(data->share)
+    Curl_share_lock(data, CURL_LOCK_DATA_DNS, CURL_LOCK_ACCESS_SINGLE);
+
+  time(&now);
+
+  /* Remove outdated and unused entries from the hostcache */
+  hostcache_prune(data->hostcache,
+                  data->set.dns_cache_timeout,
+                  now);
+
+  if(data->share)
+    Curl_share_unlock(data, CURL_LOCK_DATA_DNS);
+}
+
 #ifdef HAVE_SIGSETJMP
 /* Beware this is a global and unique instance */
 sigjmp_buf curl_jmpenv;
@@ -249,12 +266,6 @@
   dns->timestamp = now; /* used now */
   dns->inuse++;         /* mark entry as in-use */
 
-    
-  /* Remove outdated and unused entries from the hostcache */
-  hostcache_prune(data->hostcache, 
-                  data->set.dns_cache_timeout, 
-                  now);
-
   /* free the allocated entry_id again */
   free(entry_id);
 
Index: lib/hostip.h
===================================================================
RCS file: /repository/curl/lib/hostip.h,v
retrieving revision 1.26
diff -u -r1.26 hostip.h
--- lib/hostip.h	4 Oct 2003 14:50:45 -0000	1.26
+++ lib/hostip.h	15 Dec 2003 16:05:38 -0000
@@ -77,6 +77,9 @@
 /* free cached name info */
 void Curl_freednsinfo(void *freethis);
 
+/* prune old entries from the DNS cache */
+void Curl_hostcache_prune(struct SessionHandle *data);
+
 #ifdef CURLDEBUG
 void curl_freeaddrinfo(struct addrinfo *freethis,
                        int line, const char *source);
Index: lib/url.c
===================================================================
RCS file: /repository/curl/lib/url.c,v
retrieving revision 1.320
diff -u -r1.320 url.c
--- lib/url.c	15 Dec 2003 14:48:41 -0000	1.320
+++ lib/url.c	15 Dec 2003 16:05:38 -0000
@@ -3227,6 +3227,8 @@
                   NULL, Curl_scan_cache_used);
 #endif
 
+  Curl_hostcache_prune(data); /* kill old DNS cache entries */
+
   /* this calls the protocol-specific function pointer previously set */
   if(conn->curl_done)
     result = conn->curl_done(conn);
