diff options
author | Nick Mathewson <nickm@torproject.org> | 2005-03-22 20:25:51 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2005-03-22 20:25:51 +0000 |
commit | ab1d0049a22d22f31a76c988f3277c11685c0b14 (patch) | |
tree | e9913a232c56f00ee69c3b4faeb475ca5aeadced /src | |
parent | 8a763b5ae3119dbebba1887bb31ccc82bfd88e46 (diff) | |
download | tor-ab1d0049a22d22f31a76c988f3277c11685c0b14.tar.gz tor-ab1d0049a22d22f31a76c988f3277c11685c0b14.zip |
Prevent spurious closes when we put stuff on a conn that has not written for a while.
svn:r3816
Diffstat (limited to 'src')
-rw-r--r-- | src/or/main.c | 15 | ||||
-rw-r--r-- | src/or/or.h | 1 |
2 files changed, 11 insertions, 5 deletions
diff --git a/src/or/main.c b/src/or/main.c index c26d4f03cc..36917db838 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -660,6 +660,9 @@ static void run_connection_housekeeping(int i, time_t now) { connection_t *conn = connection_array[i]; or_options_t *options = get_options(); + if (conn->outbuf && !buf_datalen(conn->outbuf)) + conn->timestamp_lastempty = now; + /* Expire any directory connections that haven't sent anything for 5 min */ if (conn->type == CONN_TYPE_DIR && !conn->marked_for_close && @@ -691,11 +694,13 @@ static void run_connection_housekeeping(int i, time_t now) { i,conn->address, conn->port); connection_mark_for_close(conn); conn->hold_open_until_flushed = 1; - } else if (buf_datalen(conn->outbuf) && -// XXX will this have races were stuff just got written to the conn and we kill it? - now >= conn->timestamp_lastwritten + options->KeepalivePeriod*10) { - log_fn(LOG_INFO,"Expiring stuck connection to %d (%s:%d).", - i, conn->address, conn->port); + } else if ( + now >= conn->timestamp_lastempty + options->KeepalivePeriod*10 && + now >= conn->timestamp_lastwritten + options->KeepalivePeriod*10) { + log_fn(LOG_NOTICE,"Expiring stuck connection to %d (%s:%d). (%ul bytes to flush; %d seconds since last write)", + i, conn->address, conn->port, + (unsigned long)buf_datalen(conn->outbuf), + (int)(now-conn->timestamp_lastwritten)); connection_mark_for_close(conn); } else { /* either in clique mode, or we've got a circuit. send a padding cell. */ diff --git a/src/or/or.h b/src/or/or.h index c4e7f4f28d..92d3de3433 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -560,6 +560,7 @@ struct connection_t { time_t timestamp_lastwritten; /**< When was the last time poll() said we could write? */ time_t timestamp_created; /**< When was this connection_t created? */ + time_t timestamp_lastempty; /**< When was the outbuf last completely empty?*/ uint32_t addr; /**< IP of the other side of the connection; used to identify * routers, along with port. */ |