]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
conn: Add an helper to mark a connection as waiting for an HS descriptor
authorDavid Goulet <dgoulet@torproject.org>
Tue, 4 Dec 2018 19:00:08 +0000 (14:00 -0500)
committerDavid Goulet <dgoulet@torproject.org>
Tue, 4 Dec 2018 19:00:08 +0000 (14:00 -0500)
The transition for a connection to either become or go back in
AP_CONN_STATE_RENDDESC_WAIT state must make sure that the entry connection is
_not_ in the waiting for circuit list.

This commit implements the helper function
connection_ap_mark_as_waiting_for_renddesc() that removes the entry connection
from the pending list and then change its state. This code pattern is used in
many places in the code where next commit will remove this code duplication to
use this new helper function.

Part of #28669

Signed-off-by: David Goulet <dgoulet@torproject.org>
src/core/or/connection_edge.c
src/core/or/connection_edge.h

index 58aefcf8f297975f33761bf1385aa7b515f0aabb..96149bbb1c72fed126ae482118c7a57ac2eecc7b 100644 (file)
@@ -1354,6 +1354,21 @@ connection_ap_mark_as_non_pending_circuit(entry_connection_t *entry_conn)
   smartlist_remove(pending_entry_connections, entry_conn);
 }
 
+/** Mark <b>entry_conn</b> as waiting for a rendezvous descriptor. This
+ * function will remove the entry connection from the waiting for a circuit
+ * list (pending_entry_connections).
+ *
+ * This pattern is used across the code base because a connection in state
+ * AP_CONN_STATE_RENDDESC_WAIT must not be in the pending list. */
+void
+connection_ap_mark_as_waiting_for_renddesc(entry_connection_t *entry_conn)
+{
+  tor_assert(entry_conn);
+
+  connection_ap_mark_as_non_pending_circuit(entry_conn);
+  ENTRY_TO_CONN(entry_conn)->state = AP_CONN_STATE_RENDDESC_WAIT;
+}
+
 /* DOCDOC */
 void
 connection_ap_warn_and_unmark_if_pending_circ(entry_connection_t *entry_conn,
index 55b90d3eae3f78d290d2990eabf789d5f6194a89..b8a7365a05981415f248b859ee596f86ff69fd34 100644 (file)
@@ -126,6 +126,9 @@ void connection_ap_mark_as_pending_circuit_(entry_connection_t *entry_conn,
 #define connection_ap_mark_as_pending_circuit(c) \
   connection_ap_mark_as_pending_circuit_((c), __FILE__, __LINE__)
 void connection_ap_mark_as_non_pending_circuit(entry_connection_t *entry_conn);
+void connection_ap_mark_as_waiting_for_renddesc(
+                                       entry_connection_t *entry_conn);
+
 #define CONNECTION_AP_EXPECT_NONPENDING(c) do {                         \
     if (ENTRY_TO_CONN(c)->state == AP_CONN_STATE_CIRCUIT_WAIT) {        \
       log_warn(LD_BUG, "At %s:%d: %p was unexpectedly in circuit_wait.", \