[tor-commits] [tor/master] Debug logs to record all messages sent and delivered.

asn at torproject.org asn at torproject.org
Wed Mar 27 12:31:31 UTC 2019


commit 24b945f713a713bba0ec4f0d8297b49cbc45c5a1
Author: Nick Mathewson <nickm at torproject.org>
Date:   Sun Jan 13 16:01:44 2019 -0500

    Debug logs to record all messages sent and delivered.
---
 src/lib/dispatch/dispatch_core.c | 28 +++++++++++++++++++++++++++-
 1 file changed, 27 insertions(+), 1 deletion(-)

diff --git a/src/lib/dispatch/dispatch_core.c b/src/lib/dispatch/dispatch_core.c
index 24dfc649a..da54f9b43 100644
--- a/src/lib/dispatch/dispatch_core.c
+++ b/src/lib/dispatch/dispatch_core.c
@@ -14,6 +14,7 @@
 
 #include "lib/dispatch/dispatch.h"
 #include "lib/dispatch/dispatch_st.h"
+#include "lib/dispatch/dispatch_naming.h"
 
 #include "lib/malloc/malloc.h"
 #include "lib/log/util_bug.h"
@@ -180,6 +181,17 @@ dispatch_send_msg_unchecked(dispatch_t *d, msg_t *m)
   /* Append the message. */
   TOR_SIMPLEQ_INSERT_TAIL(&q->queue, m, next);
 
+  if (debug_logging_enabled()) {
+    char *arg = dispatch_fmt_msg_data(d, m);
+    log_debug(LD_MESG,
+              "Queued: %s (%s) from %s, on %s.",
+              get_message_id_name(m->msg),
+              arg,
+              get_subsys_id_name(m->sender),
+              get_channel_id_name(m->channel));
+    tor_free(arg);
+  }
+
   /* If we just made the queue nonempty for the first time, call the alert
    * function. */
   if (was_empty) {
@@ -199,10 +211,24 @@ dispatcher_run_msg_cbs(const dispatch_t *d, msg_t *m)
   dtbl_entry_t *ent = d->table[m->msg];
   int n_fns = ent->n_fns;
 
+  if (debug_logging_enabled()) {
+    char *arg = dispatch_fmt_msg_data(d, m);
+    log_debug(LD_MESG,
+              "Delivering: %s (%s) from %s, on %s:",
+              get_message_id_name(m->msg),
+              arg,
+              get_subsys_id_name(m->sender),
+              get_channel_id_name(m->channel));
+    tor_free(arg);
+  }
+
   int i;
   for (i=0; i < n_fns; ++i) {
-    if (ent->rcv[i].enabled)
+    if (ent->rcv[i].enabled) {
+      log_debug(LD_MESG, "  Delivering to %s.",
+                get_subsys_id_name(ent->rcv[i].sys));
       ent->rcv[i].fn(m);
+    }
   }
 }
 





More information about the tor-commits mailing list