[or-cvs] Warn in more detail when network-status serving and fetchin...

Nick Mathewson nickm at seul.org
Fri Sep 9 19:37:14 UTC 2005


Update of /home/or/cvsroot/tor/src/or
In directory moria:/tmp/cvs-serv18782/src/or

Modified Files:
	directory.c dirserv.c 
Log Message:
Warn in more detail when network-status serving and fetching fails. Also, fix a small leak.

Index: directory.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/directory.c,v
retrieving revision 1.269
retrieving revision 1.270
diff -u -d -r1.269 -r1.270
--- directory.c	9 Sep 2005 02:02:20 -0000	1.269
+++ directory.c	9 Sep 2005 19:37:12 -0000	1.270
@@ -892,8 +892,9 @@
     char *cp;
     log_fn(LOG_INFO,"Received networkstatus objects (size %d) from server '%s:%d'",(int) body_len, conn->address, conn->port);
     if (status_code != 200) {
-      log_fn(LOG_WARN,"Received http status code %d (\"%s\") from server '%s:%d'. I'll try again soon.",
-             status_code, reason, conn->address, conn->port);
+      log_fn(LOG_WARN,"Received http status code %d (\"%s\") from server '%s:%d' while fetching \"/tor/status/%s\". I'll try again soon.",
+             status_code, reason, conn->address, conn->port,
+             conn->requested_resource);
       tor_free(body); tor_free(headers); tor_free(reason);
       return -1;
     }

Index: dirserv.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/dirserv.c,v
retrieving revision 1.218
retrieving revision 1.219
diff -u -d -r1.218 -r1.219
--- dirserv.c	8 Sep 2005 21:20:20 -0000	1.218
+++ dirserv.c	9 Sep 2005 19:37:12 -0000	1.219
@@ -1028,7 +1028,7 @@
 
   if (crypto_pk_get_fingerprint(private_key, fingerprint, 0)<0) {
     log_fn(LOG_ERR, "Error computing fingerprint");
-    return -1;
+    goto done;
   }
 
   contact = get_options()->ContactInfo;
@@ -1084,11 +1084,15 @@
       format_iso_time(published, ri->published_on);
 
       if (base64_encode(identity64, sizeof(identity64),
-                        ri->identity_digest, DIGEST_LEN)<0)
+                        ri->identity_digest, DIGEST_LEN)<0) {
+        log_fn(LOG_WARN, "Unable to encode router identity digest.");
         goto done;
+      }
       if (base64_encode(digest64, sizeof(digest64),
-                        ri->signed_descriptor_digest, DIGEST_LEN)<0)
+                        ri->signed_descriptor_digest, DIGEST_LEN)<0) {
+        log_fn(LOG_WARN, "Unable to encode router descriptor digest.");
         goto done;
+      }
       identity64[BASE64_DIGEST_LEN] = '\0';
       digest64[BASE64_DIGEST_LEN] = '\0';
 
@@ -1128,8 +1132,10 @@
     goto done;
   }
 
-  if (router_append_dirobj_signature(outp,endp-outp,digest,private_key)<0)
+  if (router_append_dirobj_signature(outp,endp-outp,digest,private_key)<0) {
+    log_fn(LOG_WARN, "Unable to sign router status.");
     goto done;
+  }
 
   set_cached_dir(&the_v2_networkstatus, status, time(NULL));
   status = NULL; /* So it doesn't get double-freed. */
@@ -1172,6 +1178,7 @@
                                     the_v2_networkstatus_is_dirty,
                                     generate_v2_networkstatus,
                                     "network status list", 0);
+      log_fn(LOG_WARN, "Unable to generate an authoritative network stautus.");
       if (d)
         smartlist_add(result, d);
     }
@@ -1184,6 +1191,8 @@
       smartlist_add(result, val);
       iter = strmap_iter_next(cached_v2_networkstatus, iter);
     }
+    if (smartlist_len(result) == 0)
+      log_fn(LOG_WARN, "Client requested 'all' network status objects; we have none.");
   } else if (!strcmpstart(key, "fp/")) {
     smartlist_t *hexdigests = smartlist_create();
     smartlist_split_string(hexdigests, key+3, "+", 0, 0);
@@ -1197,9 +1206,14 @@
               the_v2_networkstatus_is_dirty + DIR_REGEN_SLACK_TIME < time(NULL))
             generate_v2_networkstatus();
           cached = strmap_get(cached_v2_networkstatus, cp);
-          if (cached)
+          if (cached) {
             smartlist_add(result, cached);
+          } else {
+            log_fn(LOG_WARN, "Don't know about any network status with fingerprint '%s'", cp);
+          }
+          tor_free(cp);
         });
+    smartlist_free(hexdigests);
   }
   return 0;
 }



More information about the tor-commits mailing list