aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2005-03-22 06:21:35 +0000
committerNick Mathewson <nickm@torproject.org>2005-03-22 06:21:35 +0000
commitc4470cbedf762292325fd3b39476dc467bce05ea (patch)
tree1e5c89758ea1fa9d25b274035122842d280160d2 /src
parentf5989afde2ec2881657135da9ce8decfce05d590 (diff)
downloadtor-c4470cbedf762292325fd3b39476dc467bce05ea.tar.gz
tor-c4470cbedf762292325fd3b39476dc467bce05ea.zip
be more explicit about why we are expiring a conn; improve logic a bit too
svn:r3808
Diffstat (limited to 'src')
-rw-r--r--src/or/main.c28
1 files changed, 19 insertions, 9 deletions
diff --git a/src/or/main.c b/src/or/main.c
index a167e20412..812d8b64a2 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -674,18 +674,28 @@ static void run_connection_housekeeping(int i, time_t now) {
if (connection_speaks_cells(conn) &&
now >= conn->timestamp_lastwritten + options->KeepalivePeriod) {
routerinfo_t *router = router_get_by_digest(conn->identity_digest);
- if ((!connection_state_is_open(conn)) ||
- (we_are_hibernating() && !circuit_get_by_conn(conn)) ||
- (!clique_mode(options) && !circuit_get_by_conn(conn) &&
- (!router || !server_mode(options) || !router_is_clique_mode(router)))) {
- /* our handshake has expired; we're hibernating;
- * or we have no circuits and we're both either OPs or normal ORs,
- * then kill it. */
- log_fn(LOG_INFO,"Expiring connection to %d (%s:%d).",
+ if (!connection_state_is_open(conn)) {
+ log_fn(LOG_INFO,"Expiring non-open OR connection to %d (%s:%d).",
i,conn->address, conn->port);
- /* flush anything waiting, e.g. a destroy for a just-expired circ */
connection_mark_for_close(conn);
conn->hold_open_until_flushed = 1;
+ } else if (we_are_hibernating() && !circuit_get_by_conn(conn) &&
+ !buf_datalen(conn->outbuf)) {
+ log_fn(LOG_INFO,"Expiring non-used OR connection to %d (%s:%d). [Hibernating.]",
+ i,conn->address, conn->port);
+ connection_mark_for_close(conn);
+ conn->hold_open_until_flushed = 1;
+ } else if (!clique_mode(options) && !circuit_get_by_conn(conn) &&
+ (!router || !server_mode(options) || !router_is_clique_mode(router))) {
+ log_fn(LOG_INFO,"Expiring non-used connection to %d (%s:%d). [Not in clique mode]",
+ i,conn->address, conn->port);
+ connection_mark_for_close(conn);
+ conn->hold_open_until_flushed = 1;
+ } else if (buf_datalen(conn->outbuf) &&
+ now >= conn->timestamp_lastwritten + options->KeepalivePeriod*10) {
+ log_fn(LOG_INFO,"Expiriing stuck connection to %d (%s:%d).",
+ i, conn->address, conn->port);
+ connection_mark_for_close(conn);
} else {
/* either in clique mode, or we've got a circuit. send a padding cell. */
log_fn(LOG_DEBUG,"Sending keepalive to (%s:%d)",