commit d0682fe0f190ce55973d86ec92978aa6b3f61f1f Author: David Goulet dgoulet@torproject.org Date: Tue Dec 4 14:00:08 2018 -0500
conn: Add an helper to mark a connection as waiting for an HS descriptor
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 | 15 +++++++++++++++ src/core/or/connection_edge.h | 3 +++ 2 files changed, 18 insertions(+)
diff --git a/src/core/or/connection_edge.c b/src/core/or/connection_edge.c index 58aefcf8f..96149bbb1 100644 --- a/src/core/or/connection_edge.c +++ b/src/core/or/connection_edge.c @@ -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, diff --git a/src/core/or/connection_edge.h b/src/core/or/connection_edge.h index 55b90d3ea..b8a7365a0 100644 --- a/src/core/or/connection_edge.h +++ b/src/core/or/connection_edge.h @@ -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.", \