[tor-commits] [tor/maint-0.2.4] Debugging log for bug 8185

nickm at torproject.org nickm at torproject.org
Thu Apr 11 05:47:00 UTC 2013


commit 7d1ade251bad76c82b3f1288097587e0fbd1c4ae
Author: Nick Mathewson <nickm at torproject.org>
Date:   Tue Mar 19 17:00:40 2013 -0400

    Debugging log for bug 8185
    
    If the bug recurs, log the filename and line number that triggered it
---
 changes/bug8185_diagnostic |    3 +++
 src/or/relay.c             |   22 +++++++++++++++-------
 src/or/relay.h             |   10 ++++++++--
 3 files changed, 26 insertions(+), 9 deletions(-)

diff --git a/changes/bug8185_diagnostic b/changes/bug8185_diagnostic
new file mode 100644
index 0000000..b0f8884
--- /dev/null
+++ b/changes/bug8185_diagnostic
@@ -0,0 +1,3 @@
+  o Minor features:
+    - Improve debugging output to attempt to diagnose the underlying
+      cause of bug 8185.
diff --git a/src/or/relay.c b/src/or/relay.c
index 1da9932..c71fe2a 100644
--- a/src/or/relay.c
+++ b/src/or/relay.c
@@ -379,15 +379,22 @@ relay_crypt(circuit_t *circ, cell_t *cell, cell_direction_t cell_direction,
 static int
 circuit_package_relay_cell(cell_t *cell, circuit_t *circ,
                            cell_direction_t cell_direction,
-                           crypt_path_t *layer_hint, streamid_t on_stream)
+                           crypt_path_t *layer_hint, streamid_t on_stream,
+                           const char *filename, int lineno)
 {
   channel_t *chan; /* where to send the cell */
 
   if (cell_direction == CELL_DIRECTION_OUT) {
     crypt_path_t *thishop; /* counter for repeated crypts */
     chan = circ->n_chan;
-    if (!CIRCUIT_IS_ORIGIN(circ) || !chan) {
-      log_warn(LD_BUG,"outgoing relay cell has n_chan==NULL. Dropping.");
+    if (!chan) {
+      log_warn(LD_BUG,"outgoing relay cell sent from %s:%d has n_chan==NULL."
+               " Dropping.", filename, lineno);
+      return 0; /* just drop it */
+    }
+    if (!CIRCUIT_IS_ORIGIN(circ)) {
+      log_warn(LD_BUG,"outgoing relay cell sent from %s:%d on non-origin "
+               "circ. Dropping.", filename, lineno);
       return 0; /* just drop it */
     }
 
@@ -548,9 +555,10 @@ relay_command_to_string(uint8_t command)
  * return 0.
  */
 int
-relay_send_command_from_edge(streamid_t stream_id, circuit_t *circ,
-                             uint8_t relay_command, const char *payload,
-                             size_t payload_len, crypt_path_t *cpath_layer)
+relay_send_command_from_edge_(streamid_t stream_id, circuit_t *circ,
+                              uint8_t relay_command, const char *payload,
+                              size_t payload_len, crypt_path_t *cpath_layer,
+                              const char *filename, int lineno)
 {
   cell_t cell;
   relay_header_t rh;
@@ -633,7 +641,7 @@ relay_send_command_from_edge(streamid_t stream_id, circuit_t *circ,
   }
 
   if (circuit_package_relay_cell(&cell, circ, cell_direction, cpath_layer,
-                                 stream_id) < 0) {
+                                 stream_id, filename, lineno) < 0) {
     log_warn(LD_BUG,"circuit_package_relay_cell failed. Closing.");
     circuit_mark_for_close(circ, END_CIRC_REASON_INTERNAL);
     return -1;
diff --git a/src/or/relay.h b/src/or/relay.h
index 7e59838..229fb4f 100644
--- a/src/or/relay.h
+++ b/src/or/relay.h
@@ -20,9 +20,15 @@ int circuit_receive_relay_cell(cell_t *cell, circuit_t *circ,
 
 void relay_header_pack(uint8_t *dest, const relay_header_t *src);
 void relay_header_unpack(relay_header_t *dest, const uint8_t *src);
-int relay_send_command_from_edge(streamid_t stream_id, circuit_t *circ,
+int relay_send_command_from_edge_(streamid_t stream_id, circuit_t *circ,
                                uint8_t relay_command, const char *payload,
-                               size_t payload_len, crypt_path_t *cpath_layer);
+                               size_t payload_len, crypt_path_t *cpath_layer,
+                               const char *filename, int lineno);
+#define relay_send_command_from_edge(stream_id, circ, relay_command, payload, \
+                                     payload_len, cpath_layer)          \
+  relay_send_command_from_edge_((stream_id), (circ), (relay_command),   \
+                                (payload), (payload_len), (cpath_layer), \
+                                __FILE__, __LINE__)
 int connection_edge_send_command(edge_connection_t *fromconn,
                                  uint8_t relay_command, const char *payload,
                                  size_t payload_len);





More information about the tor-commits mailing list