[or-cvs] r17550: {tor} Give a better error when something has changed our descripto (in tor/trunk: . src/or)

nickm at seul.org nickm at seul.org
Wed Dec 10 03:01:26 UTC 2008


Author: nickm
Date: 2008-12-09 22:01:26 -0500 (Tue, 09 Dec 2008)
New Revision: 17550

Modified:
   tor/trunk/ChangeLog
   tor/trunk/src/or/routerlist.c
Log:
Give a better error when something has changed our descriptor cache out from under us.  Based on patch from Karsten.  Addresses bug 885.

Modified: tor/trunk/ChangeLog
===================================================================
--- tor/trunk/ChangeLog	2008-12-10 01:46:51 UTC (rev 17549)
+++ tor/trunk/ChangeLog	2008-12-10 03:01:26 UTC (rev 17550)
@@ -12,6 +12,9 @@
       been fetched and validated.
     - Finally remove deprecated "EXTENEDED_FORMAT" feature.  It has
       been called EXTENDED_EVENTS since 0.1.2.4-alpha.
+    - When we realize that another process has modified our cached
+      descriptors, print out a more useful error message rather than
+      triggering an assertion. Fixes bug 885.
 
   o Minor bugfixes:
     - Resume using the correct "REASON=" stream when telling the

Modified: tor/trunk/src/or/routerlist.c
===================================================================
--- tor/trunk/src/or/routerlist.c	2008-12-10 01:46:51 UTC (rev 17549)
+++ tor/trunk/src/or/routerlist.c	2008-12-10 03:01:26 UTC (rev 17550)
@@ -2211,6 +2211,11 @@
     if (store && store->mmap) {
       tor_assert(desc->saved_offset + len <= store->mmap->size);
       r = store->mmap->data + offset;
+    } else if (store) {
+      log_err(LD_DIR, "We couldn't read a descriptor that is supposedly "
+              "mmaped in our cache.  Is another process running in our data "
+              "directory?  Exiting.");
+      exit(1);
     }
   }
   if (!r) /* no mmap, or not in cache. */
@@ -2221,11 +2226,11 @@
   if (!with_annotations) {
     if (memcmp("router ", r, 7) && memcmp("extra-info ", r, 11)) {
       char *cp = tor_strndup(r, 64);
-      log_err(LD_DIR, "descriptor at %p begins with unexpected string %s",
+      log_err(LD_DIR, "descriptor at %p begins with unexpected string %s.  "
+              "Is another process running in our data directory?  Exiting.",
               desc, escaped(cp));
-      tor_free(cp);
+      exit(1);
     }
-    tor_assert(!memcmp("router ", r, 7) || !memcmp("extra-info ", r, 11));
   }
 
   return r;



More information about the tor-commits mailing list