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).
This commit is contained in:
Nick Mathewson 2015-12-16 18:49:23 -05:00
parent 3317cd3a1f
commit 613e0e1c1a

View File

@ -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);