From 2c1d7cf674b3d8b4ec3ca35df69901c82723032e Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Fri, 26 Oct 2007 22:50:40 +0000 Subject: r16194@catbus: nickm | 2007-10-26 18:37:02 -0400 Keep circuitless TLS connections open for 1.5 x MaxCircuitDirtiness: this ensures that we don't thrash closing and repoening connections to our guards. svn:r12218 --- src/or/main.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/or') diff --git a/src/or/main.c b/src/or/main.c index 3c0b4ae43..08b5e805e 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -764,19 +764,23 @@ run_connection_housekeeping(int i, time_t now) the connection or send a keepalive, depending. */ if (now >= conn->timestamp_lastwritten + options->KeepalivePeriod) { routerinfo_t *router = router_get_by_digest(or_conn->identity_digest); + int maxCircuitlessPeriod = options->MaxCircuitDirtiness*3/2; if (!connection_state_is_open(conn)) { + /* We never managed to actually get this connection open and happy. */ log_info(LD_OR,"Expiring non-open OR connection to fd %d (%s:%d).", conn->s,conn->address, conn->port); connection_mark_for_close(conn); conn->hold_open_until_flushed = 1; } else if (we_are_hibernating() && !or_conn->n_circuits && !buf_datalen(conn->outbuf)) { + /* We're hibernating, there's no circuits, and nothing to flush.*/ log_info(LD_OR,"Expiring non-used OR connection to fd %d (%s:%d) " "[Hibernating or exiting].", conn->s,conn->address, conn->port); connection_mark_for_close(conn); conn->hold_open_until_flushed = 1; } else if (!clique_mode(options) && !or_conn->n_circuits && + now >= conn->timestamp_lastwritten + maxCircuitlessPeriod && (!router || !server_mode(options) || !router_is_clique_mode(router))) { log_info(LD_OR,"Expiring non-used OR connection to fd %d (%s:%d) " -- cgit v1.2.3