Arrange to call dns_init() for host_find_byname() as well as for
[exim.git] / src / src / routers / iplookup.c
index e7fba34470426cd1253a99bf9387f95a26074ad1..069c0dda1a333aa873d62e2968099cadc6602514 100644 (file)
@@ -1,10 +1,10 @@
-/* $Cambridge: exim/src/src/routers/iplookup.c,v 1.4 2005/09/12 15:09:55 ph10 Exp $ */
+/* $Cambridge: exim/src/src/routers/iplookup.c,v 1.8 2006/10/09 14:36:25 ph10 Exp $ */
 
 /*************************************************
 *     Exim - an Internet mail transport agent    *
 *************************************************/
 
-/* Copyright (c) University of Cambridge 1995 - 2005 */
+/* Copyright (c) University of Cambridge 1995 - 2006 */
 /* See the file NOTICE for conditions of use and distribution. */
 
 
@@ -202,11 +202,11 @@ while ((hostname = string_nextinlist(&listptr, &sep, host_buffer,
   host->mx = MX_NONE;
   host->next = NULL;
 
-  if (string_is_ip_address(host->name, NULL))
+  if (string_is_ip_address(host->name, NULL) != 0)
     host->address = host->name;
   else
     {
-    int rc = host_find_byname(host, NULL, NULL, TRUE);
+    int rc = host_find_byname(host, NULL, HOST_FIND_QUALIFY_SINGLE, NULL, TRUE);
     if (rc == HOST_FIND_FAILED || rc == HOST_FIND_AGAIN) continue;
     }
 
@@ -240,6 +240,7 @@ while ((hostname = string_nextinlist(&listptr, &sep, host_buffer,
 
     if (ip_connect(query_socket, host_af, h->address,ob->port, ob->timeout) < 0)
       {
+      close(query_socket);
       DEBUG(D_route)
         debug_printf("connection to %s failed: %s\n", h->address,
           strerror(errno));