[or-cvs] Workarounds for a couple of pieces of windows strangeness.

Nick Mathewson nickm at seul.org
Wed Apr 28 19:35:14 UTC 2004


Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/tmp/cvs-serv14491/src/or

Modified Files:
	dns.c routerlist.c 
Log Message:
Workarounds for a couple of pieces of windows strangeness.

Index: dns.c
===================================================================
RCS file: /home/or/cvsroot/src/or/dns.c,v
retrieving revision 1.78
retrieving revision 1.79
diff -u -d -r1.78 -r1.79
--- dns.c	25 Apr 2004 20:37:37 -0000	1.78
+++ dns.c	28 Apr 2004 19:35:12 -0000	1.79
@@ -451,7 +451,6 @@
   char address[MAX_ADDRESSLEN];
   unsigned char address_len;
   char answer[5];
-  struct hostent *rent;
   int *fdarray = data;
   int fd;
 
@@ -475,21 +474,17 @@
     }
     address[address_len] = 0; /* null terminate it */
 
-    rent = gethostbyname(address);
-    if (!rent) {
-      if(h_errno == TRY_AGAIN) { /* transient error -- don't cache it */
+    switch (tor_lookup_hostname(address, (uint32_t*)answer+1)) {
+      case 1:
         log_fn(LOG_INFO,"Could not resolve dest addr %s (transient).",address);
         answer[0] = DNS_RESOLVE_FAILED_TRANSIENT;
-      } else { /* permanent error, can be cached */
+        break;
+      case -1:
         log_fn(LOG_INFO,"Could not resolve dest addr %s (permanent).",address);
         answer[0] = DNS_RESOLVE_FAILED_PERMANENT;
-      }
-      memset(answer+1,0,4);
-    } else {
-      tor_assert(rent->h_length == 4); /* break to remind us if we move away from ipv4 */
-      answer[0] = DNS_RESOLVE_SUCCEEDED;
-      memcpy(answer+1, rent->h_addr, 4);
-      log_fn(LOG_INFO,"Resolved address '%s'.",address);
+      case 0:
+        log_fn(LOG_INFO,"Resolved address '%s'.",address);
+        answer[0] = DNS_RESOLVE_SUCCEEDED;
     }
     if(write_all(fd, answer, 5, 1) != 5) {
       log_fn(LOG_ERR,"writing answer failed. Child exiting.");

Index: routerlist.c
===================================================================
RCS file: /home/or/cvsroot/src/or/routerlist.c,v
retrieving revision 1.65
retrieving revision 1.66
diff -u -d -r1.65 -r1.66
--- routerlist.c	25 Apr 2004 21:32:04 -0000	1.65
+++ routerlist.c	28 Apr 2004 19:35:12 -0000	1.66
@@ -507,14 +507,11 @@
 {
   struct hostent *rent;
 
-  rent = (struct hostent *)gethostbyname(router->address);
-  if (!rent) {
+  if (tor_lookup_hostname(router->address, &router->addr)) {
     log_fn(LOG_WARN,"Could not get address for router %s (%s).",
            router->address, router->nickname);
     return -1;
   }
-  tor_assert(rent->h_length == 4);
-  memcpy(&router->addr, rent->h_addr,rent->h_length);
   router->addr = ntohl(router->addr); /* get it back into host order */
 
   return 0;



More information about the tor-commits mailing list