[or-cvs] r9280: Re-enable warning when we resolve an already resolved addres (in tor/trunk: . src/or)

nickm at seul.org nickm at seul.org
Sat Jan 6 06:26:50 UTC 2007


Author: nickm
Date: 2007-01-06 01:26:46 -0500 (Sat, 06 Jan 2007)
New Revision: 9280

Modified:
   tor/trunk/
   tor/trunk/ChangeLog
   tor/trunk/src/or/dns.c
Log:
 r11862 at Kushana:  nickm | 2007-01-06 01:05:15 -0500
 Re-enable warning when we resolve an already resolved address.  We only warn here now if the address is not a testing address.  Also, refactor out a function to check whether an address is used for testing.



Property changes on: tor/trunk
___________________________________________________________________
 svk:merge ticket from /tor/trunk [r11862] on c95137ef-5f19-0410-b913-86e773d04f59

Modified: tor/trunk/ChangeLog
===================================================================
--- tor/trunk/ChangeLog	2007-01-06 05:42:31 UTC (rev 9279)
+++ tor/trunk/ChangeLog	2007-01-06 06:26:46 UTC (rev 9280)
@@ -20,7 +20,11 @@
       server status events so controllers can learn about Tor's progress in
       deciding whether it's reachable from the outside.
 
+  o Minor bugfixes:
+    - Restore a warning message if we accidentally resolve an address that
+      we weren't planning to resolve.
 
+
 Changes in version 0.1.2.5-alpha - 2007-01-06
   o Major features:
     - Enable write limiting as well as read limiting. Now we sacrifice

Modified: tor/trunk/src/or/dns.c
===================================================================
--- tor/trunk/src/or/dns.c	2007-01-06 05:42:31 UTC (rev 9279)
+++ tor/trunk/src/or/dns.c	2007-01-06 06:26:46 UTC (rev 9280)
@@ -886,6 +886,14 @@
   set_expiry(resolve, time(NULL) + dns_get_expiry_ttl(ttl));
 }
 
+static INLINE int
+is_test_address(const char *address)
+{
+  or_options_t *options = get_options();
+  return options->ServerDNSTestAddresses &&
+    smartlist_string_isin_case(options->ServerDNSTestAddresses, address);
+}
+
 /** Called on the OR side when a DNS worker or the eventdns library tells us
  * the outcome of a DNS resolve: tell all pending connections about the result
  * of the lookup, and cache the value.  (<b>address</b> is a NUL-terminated
@@ -909,10 +917,8 @@
 
   resolve = HT_FIND(cache_map, &cache_root, &search);
   if (!resolve) {
-    or_options_t *options = get_options();
-    int is_test_address = options->ServerDNSTestAddresses &&
-      smartlist_string_isin_case(options->ServerDNSTestAddresses, address);
-    if (!is_test_address)
+    int is_test_addr = is_test_address(address);
+    if (!is_test_addr)
       log_info(LD_EXIT,"Resolved unasked address %s; caching anyway.",
                escaped_safe_str(address));
     add_answer_to_cache(address, is_reverse, addr, hostname, outcome, ttl);
@@ -923,9 +929,11 @@
   if (resolve->state != CACHE_STATE_PENDING) {
     /* XXXX Maybe update addr? or check addr for consistency? Or let
      * VALID replace FAILED? */
-    log_info(LD_EXIT, "Resolved %s which was already resolved; ignoring",
-             escaped_safe_str(address));
-    /* XXXX012 this triggers in ordinary life. nick says it's a bug. */
+    int is_test_addr = is_test_address(address);
+    if (!is_test_addr)
+      log_notice(LD_EXIT,
+                 "Resolved %s which was already resolved; ignoring",
+                 escaped_safe_str(address));
     tor_assert(resolve->pending_connections == NULL);
     return;
   }
@@ -1602,11 +1610,9 @@
       status = DNS_RESOLVE_FAILED_TRANSIENT;
   }
   if (was_wildcarded) {
-    or_options_t *options = get_options();
-    int is_test_address = options->ServerDNSTestAddresses &&
-      smartlist_string_isin_case(options->ServerDNSTestAddresses, hostname);
+    int is_test_addr = is_test_address(hostname);
 
-    if (is_test_address) {
+    if (is_test_addr) {
       /* Ick.  We're getting redirected on known-good addresses.  Our DNS
        * server must really hate us.  */
       add_wildcarded_test_address(hostname);



More information about the tor-commits mailing list