[or-cvs] Stop logging events that happen to uninitialized digests

Nick Mathewson nickm at seul.org
Tue Aug 17 07:12:07 UTC 2004


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

Modified Files:
	rephist.c 
Log Message:
Stop logging events that happen to uninitialized digests

Index: rephist.c
===================================================================
RCS file: /home/or/cvsroot/src/or/rephist.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- rephist.c	9 Aug 2004 04:27:42 -0000	1.24
+++ rephist.c	17 Aug 2004 07:12:05 -0000	1.25
@@ -55,6 +55,9 @@
   char hexid[HEX_DIGEST_LEN+1];
   base16_encode(hexid, HEX_DIGEST_LEN+1, id, DIGEST_LEN);
 
+  if (!strcmp(hexid, "0000000000000000000000000000000000000000"))
+    return NULL;
+
   hist = (or_history_t*) strmap_get(history_map, hexid);
   if (!hist) {
     hist = tor_malloc_zero(sizeof(or_history_t));
@@ -76,7 +79,11 @@
   link_history_t *lhist;
   char to_hexid[HEX_DIGEST_LEN+1];
   orhist = get_or_history(from_id);
+  if (!orhist)
+    return NULL;
   base16_encode(to_hexid, HEX_DIGEST_LEN+1, to_id, DIGEST_LEN);
+  if (!strcmp(hexid, "0000000000000000000000000000000000000000"))
+    return NULL;
   lhist = (link_history_t*) strmap_get(orhist->link_history_map, to_hexid);
   if (!lhist) {
     lhist = tor_malloc_zero(sizeof(link_history_t));
@@ -117,6 +124,8 @@
 {
   or_history_t *hist;
   hist = get_or_history(id);
+  if (!hist)
+    return;
   ++hist->n_conn_fail;
   if (hist->up_since) {
     hist->uptime += (when - hist->up_since);
@@ -133,6 +142,8 @@
 {
   or_history_t *hist;
   hist = get_or_history(id);
+  if (!hist)
+    return;
   ++hist->n_conn_ok;
   if (hist->down_since) {
     hist->downtime += (when - hist->down_since);
@@ -149,6 +160,8 @@
 {
   or_history_t *hist;
   hist = get_or_history(id);
+  if (!hist)
+    return;
   ++hist->n_conn_ok;
   if (hist->up_since) {
     hist->uptime += (when - hist->up_since);
@@ -171,6 +184,8 @@
     return;
   }
   hist = get_or_history(id);
+  if (!hist)
+    return;
   if (hist->up_since) {
     hist->uptime += (when - hist->up_since);
     hist->up_since = 0;
@@ -189,6 +204,8 @@
   link_history_t *hist;
   /* log_fn(LOG_WARN, "EXTEND SUCCEEDED: %s->%s",from_name,to_name); */
   hist = get_link_history(from_id, to_id);
+  if (!hist)
+    return;
   ++hist->n_extend_ok;
 }
 
@@ -201,6 +218,8 @@
   link_history_t *hist;
   /* log_fn(LOG_WARN, "EXTEND FAILED: %s->%s",from_name,to_name); */
   hist = get_link_history(from_id, to_id);
+  if (!hist)
+    return;
   ++hist->n_extend_fail;
 }
 
@@ -247,7 +266,9 @@
         or_history->n_conn_ok, or_history->n_conn_fail+or_history->n_conn_ok,
         upt, upt+downt, uptime*100.0);
 
-    strcpy(buffer, "    Good extend attempts: ");
+    if (!strmap_isempty(or_history->link_history_map)) {
+      strcpy(buffer, "    Good extend attempts: ");
+    }
     len = strlen(buffer);
     for (lhist_it = strmap_iter_init(or_history->link_history_map);
          !strmap_iter_done(lhist_it);



More information about the tor-commits mailing list