[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/release-0.2.4] Log fname:lineno in log messages for #7164



commit adfc3de83308982f91c88e1e6c68dc37d2467746
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date:   Wed Mar 13 10:42:58 2013 -0400

    Log fname:lineno in log messages for #7164
    
    This should help us track down #7164 at last.
---
 changes/bug7164_diagnostic |    4 ++++
 src/or/microdesc.c         |   20 +++++++++++---------
 src/or/microdesc.h         |    4 +++-
 3 files changed, 18 insertions(+), 10 deletions(-)

diff --git a/changes/bug7164_diagnostic b/changes/bug7164_diagnostic
new file mode 100644
index 0000000..8bedfc4
--- /dev/null
+++ b/changes/bug7164_diagnostic
@@ -0,0 +1,4 @@
+  o Minor features (bug diagnostic):
+    - If we fail to free a microdescriptor because of bug #7164, log
+      the filename and line number from which we tried to free it.
+      This should help us finally fix #7164.
diff --git a/src/or/microdesc.c b/src/or/microdesc.c
index ac48930..e835f98 100644
--- a/src/or/microdesc.c
+++ b/src/or/microdesc.c
@@ -532,7 +532,7 @@ microdesc_check_counts(void)
 /** Deallocate a single microdescriptor.  Note: the microdescriptor MUST have
  * previously been removed from the cache if it had ever been inserted. */
 void
-microdesc_free(microdesc_t *md)
+microdesc_free_(microdesc_t *md, const char *fname, int lineno)
 {
   if (!md)
     return;
@@ -543,12 +543,12 @@ microdesc_free(microdesc_t *md)
     microdesc_cache_t *cache = get_microdesc_cache();
     microdesc_t *md2 = HT_FIND(microdesc_map, &cache->map, md);
     if (md2 == md) {
-      log_warn(LD_BUG, "microdesc_free() called, but md was still in "
-               "microdesc_map");
+      log_warn(LD_BUG, "microdesc_free() called from %s:%d, but md was still "
+               "in microdesc_map", fname, lineno);
       HT_REMOVE(microdesc_map, &cache->map, md);
     } else {
-      log_warn(LD_BUG, "microdesc_free() called with held_in_map set, but "
-               "microdesc was not in the map.");
+      log_warn(LD_BUG, "microdesc_free() called from %s:%d with held_in_map "
+               "set, but microdesc was not in the map.", fname, lineno);
     }
     tor_fragile_assert();
   }
@@ -562,11 +562,13 @@ microdesc_free(microdesc_t *md)
         }
       });
     if (found) {
-      log_warn(LD_BUG, "microdesc_free() called, but md was still referenced "
-               "%d node(s); held_by_nodes == %u", found, md->held_by_nodes);
+      log_warn(LD_BUG, "microdesc_free() called from %s:%d, but md was still "
+               "referenced %d node(s); held_by_nodes == %u",
+               fname, lineno, found, md->held_by_nodes);
     } else {
-      log_warn(LD_BUG, "microdesc_free() called with held_by_nodes set to %u, "
-               "but md was not referenced by any nodes", md->held_by_nodes);
+      log_warn(LD_BUG, "microdesc_free() called from %s:%d with held_by_nodes "
+               "set to %u, but md was not referenced by any nodes",
+               fname, lineno, md->held_by_nodes);
     }
     tor_fragile_assert();
   }
diff --git a/src/or/microdesc.h b/src/or/microdesc.h
index 4e58aa3..7adb8c6 100644
--- a/src/or/microdesc.h
+++ b/src/or/microdesc.h
@@ -39,7 +39,9 @@ smartlist_t *microdesc_list_missing_digest256(networkstatus_t *ns,
                                               int downloadable_only,
                                               digestmap_t *skip);
 
-void microdesc_free(microdesc_t *md);
+void microdesc_free_(microdesc_t *md, const char *fname, int line);
+#define microdesc_free(md) \
+  microdesc_free_((md), __FILE__, __LINE__)
 void microdesc_free_all(void);
 
 void update_microdesc_downloads(time_t now);



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits