mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-11 13:43:47 +01:00
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>
This commit is contained in:
parent
0906dde9d5
commit
d0682fe0f1
@ -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,
|
||||
|
@ -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.", \
|
||||
|
Loading…
Reference in New Issue
Block a user