[tor-commits] [tor/master] Move pending-connection code into connection_ap_about_to_close

nickm at torproject.org nickm at torproject.org
Wed Dec 16 23:57:24 UTC 2015


commit 613e0e1c1ac3e44bad7a876147c49bc232460df2
Author: Nick Mathewson <nickm at torproject.org>
Date:   Wed Dec 16 18:49:23 2015 -0500

    Move pending-connection code into connection_ap_about_to_close
    
    It is AP-specific, so that's where it belongs.  This shouldn't have
    caused a bug, but due to #17876, we were never actually calling
    connection_edge_about_to_close from connection_ap_about_to_close,
    causing bug #17874 (aka bug #17752).
---
 src/or/connection_edge.c |   37 ++++++++++++++++---------------------
 1 file changed, 16 insertions(+), 21 deletions(-)

diff --git a/src/or/connection_edge.c b/src/or/connection_edge.c
index 961e49a..fdb16a2 100644
--- a/src/or/connection_edge.c
+++ b/src/or/connection_edge.c
@@ -527,27 +527,6 @@ connection_edge_about_to_close(edge_connection_t *edge_conn)
              conn->marked_for_close_file, conn->marked_for_close);
     tor_fragile_assert();
   }
-
-  if (TO_CONN(edge_conn)->type != CONN_TYPE_AP ||
-      PREDICT_UNLIKELY(NULL == pending_entry_connections))
-    return;
-
-  entry_connection_t *entry_conn = EDGE_TO_ENTRY_CONN(edge_conn);
-
-  if (TO_CONN(edge_conn)->state == AP_CONN_STATE_CIRCUIT_WAIT) {
-    smartlist_remove(pending_entry_connections, entry_conn);
-  }
-
-#if 1
-  /* Check to make sure that this isn't in pending_entry_connections if it
-   * didn't actually belong there. */
-  if (TO_CONN(edge_conn)->type == CONN_TYPE_AP &&
-      smartlist_contains(pending_entry_connections, entry_conn)) {
-    log_warn(LD_BUG, "What was %p doing in pending_entry_connections???",
-             entry_conn);
-    smartlist_remove(pending_entry_connections, entry_conn);
-  }
-#endif
 }
 
 /** Called when we're about to finally unlink and free an AP (client)
@@ -577,6 +556,22 @@ connection_ap_about_to_close(entry_connection_t *entry_conn)
              conn->marked_for_close_file, conn->marked_for_close);
     dnsserv_reject_request(entry_conn);
   }
+
+  if (TO_CONN(edge_conn)->state == AP_CONN_STATE_CIRCUIT_WAIT) {
+    smartlist_remove(pending_entry_connections, entry_conn);
+  }
+
+#if 1
+  /* Check to make sure that this isn't in pending_entry_connections if it
+   * didn't actually belong there. */
+  if (TO_CONN(edge_conn)->type == CONN_TYPE_AP &&
+      smartlist_contains(pending_entry_connections, entry_conn)) {
+    log_warn(LD_BUG, "What was %p doing in pending_entry_connections???",
+             entry_conn);
+    smartlist_remove(pending_entry_connections, entry_conn);
+  }
+#endif
+
   control_event_stream_bandwidth(edge_conn);
   control_event_stream_status(entry_conn, STREAM_EVENT_CLOSED,
                               edge_conn->end_reason);





More information about the tor-commits mailing list