From 56dfc3151ffd246e66697a02635c202bbdc31558 Mon Sep 17 00:00:00 2001 From: Roger Dingledine Date: Sat, 27 Mar 2004 05:45:52 +0000 Subject: work around a tsocks bug when an AP connection dies early, be sure to do a socks reject for it. if you just hang up, tsocks goes into an infinite loop. svn:r1352 --- src/or/connection.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'src/or/connection.c') diff --git a/src/or/connection.c b/src/or/connection.c index c7f3867d04..75804ee02d 100644 --- a/src/or/connection.c +++ b/src/or/connection.c @@ -199,8 +199,14 @@ _connection_mark_for_close(connection_t *conn, char reason) } /* No special processing needed. */ break; - case CONN_TYPE_EXIT: case CONN_TYPE_AP: + if (conn->socks_request->has_finished == 0) { + log_fn(LOG_INFO,"Cleaning up AP -- sending socks reject."); + connection_ap_handshake_socks_reply(conn, NULL, 0, 0); + conn->socks_request->has_finished = 1; + } + /* fall through, to do things for both ap and exit */ + case CONN_TYPE_EXIT: if (conn->state == EXIT_CONN_STATE_RESOLVING) connection_dns_remove(conn); if (!conn->has_sent_end && reason && @@ -1004,13 +1010,16 @@ void assert_connection_ok(connection_t *conn, time_t now) assert(!conn->done_sending); assert(!conn->done_receiving); } else { - if(conn->type == CONN_TYPE_AP && conn->state == AP_CONN_STATE_OPEN) - assert(conn->cpath_layer); - if(conn->cpath_layer) - assert_cpath_layer_ok(conn->cpath_layer); /* XXX unchecked: package window, deliver window. */ } - if (conn->type != CONN_TYPE_AP) { + if (conn->type == CONN_TYPE_AP) { + assert(conn->socks_request); + if (conn->state == AP_CONN_STATE_OPEN) { + assert(conn->socks_request->has_finished); + assert(conn->cpath_layer); + assert_cpath_layer_ok(conn->cpath_layer); + } + } else { assert(!conn->socks_request); } -- cgit v1.2.3-54-g00ecf