diff options
author | Nick Mathewson <nickm@torproject.org> | 2004-03-03 02:07:57 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2004-03-03 02:07:57 +0000 |
commit | 6379dbbe2a2d19f30468ce03ca1684f332df33c5 (patch) | |
tree | 6b594e3c282b8bd3f9050d16a1dad298db828e9d /src | |
parent | 49281424aed515b4c04ea0ad2c859757b1f56984 (diff) | |
download | tor-6379dbbe2a2d19f30468ce03ca1684f332df33c5.tar tor-6379dbbe2a2d19f30468ce03ca1684f332df33c5.tar.gz |
warn more when losing data on closed/marked connections.
svn:r1203
Diffstat (limited to 'src')
-rw-r--r-- | src/or/connection.c | 4 | ||||
-rw-r--r-- | src/or/main.c | 11 |
2 files changed, 12 insertions, 3 deletions
diff --git a/src/or/connection.c b/src/or/connection.c index e0e29cfca..934543c6d 100644 --- a/src/or/connection.c +++ b/src/or/connection.c @@ -153,6 +153,10 @@ void connection_close_immediate(connection_t *conn) log_fn(LOG_WARN,"Attempt to close already-closed connection."); return; } + if (conn->outbuf_flushlen) { + log_fn(LOG_INFO,"Closing connection (fd %d, type %d, state %d) with data on outbuf.", + conn->s, conn->type, conn->state); + } close(conn->s); conn->s = -1; if(!connection_is_listener(conn)) { diff --git a/src/or/main.c b/src/or/main.c index c73c30d35..850616cba 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -229,18 +229,23 @@ static void conn_close_if_marked(int i) { assert_connection_ok(conn, time(NULL)); if(conn->marked_for_close) { log_fn(LOG_INFO,"Cleaning up connection (fd %d).",conn->s); - if(conn->s >= 0) { + if(conn->s >= 0 && connection_wants_to_flush(conn)) { /* -1 means it's an incomplete edge connection, or that the socket * has already been closed as unflushable. */ /* FIXME there's got to be a better way to check for this -- and make other checks? */ + log_fn(LOG_WARN, + "Conn (fd %d, type %d, state %d) marked for close, but wants to flush.", + conn->s, conn->type, conn->state); + if(connection_speaks_cells(conn)) { - if(conn->state == OR_CONN_STATE_OPEN) + if(conn->state == OR_CONN_STATE_OPEN && conn->outbuf_flushlen) { flush_buf_tls(conn->tls, conn->outbuf, &conn->outbuf_flushlen); + } } else { flush_buf(conn->s, conn->outbuf, &conn->outbuf_flushlen); } if(connection_wants_to_flush(conn) && buf_datalen(conn->outbuf)) { - log_fn(LOG_WARN,"Conn (socket %d) still wants to flush. Losing %d bytes!", + log_fn(LOG_WARN,"Conn (fd %d) still wants to flush. Losing %d bytes!", conn->s, (int)buf_datalen(conn->outbuf)); } } |