run_connection_housekeeping() closes circuits early
Due perhaps to bug #1772 (moved), my circuitbuildtimeout is growing very big:
Aug 17 14:59:00.189 [notice] Based on 1000 circuit times, it looks like we need to wait longer for circuits to finish. We will now assume a circuit is too slow to use after waiting 255 seconds.
And once it's this big, run_connection_housekeeping() starts killing OR connections that haven't finished handshaking yet:
Aug 17 15:06:03.012 [info] run_connection_housekeeping(): Expiring non-used OR connection to fd 18 (38.229.70.33:9001) [idle 180]. Aug 17 15:06:03.012 [info] run_connection_housekeeping(): Expiring non-used OR connection to fd 11 (85.25.130.135:443) [idle 180]. Aug 17 15:06:03.012 [debug] conn_close_if_marked(): Cleaning up connection (fd 18). Aug 17 15:06:03.012 [debug] circuit_n_conn_done(): or_conn to FordModelA/38.229.70.33, status=0 Aug 17 15:06:03.012 [info] circuit_n_conn_done(): or_conn failed. Closing circ. Aug 17 15:06:03.012 [info] circuit_build_failed(): Our circuit died before the first hop with no connection Aug 17 15:06:03.013 [debug] circuit_increment_failure_count(): n_circuit_failures now 1. Aug 17 15:06:03.013 [debug] connection_remove(): removing socket 18 (type OR), n_conns now 20 Aug 17 15:06:03.013 [debug] _connection_free(): closing fd 18. Aug 17 15:06:03.013 [debug] conn_close_if_marked(): Cleaning up connection (fd 11). Aug 17 15:06:03.013 [debug] connection_remove(): removing socket 11 (type OR), n_conns now 19 Aug 17 15:06:03.013 [debug] _connection_free(): closing fd 11.
So the first issue is: why the heck is my network taking >180 seconds to TLS handshake with this relay? Probably something about my network stability, plus the results of bug #1772 (moved).
The second question is: why are we culling the OR connection when there's a circuit that isn't connected yet but wants to be? That sounds like a check we forgot to add (that didn't matter when the timeout was 15 minutes, but now matters when the timeout is 3 minutes).