[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] do all the heavy lifting in connection_about_to_close_conne...
- To: or-cvs@freehaven.net
- Subject: [or-cvs] do all the heavy lifting in connection_about_to_close_conne...
- From: arma@seul.org (Roger Dingledine)
- Date: Wed, 19 May 2004 19:32:23 -0400 (EDT)
- Delivered-to: archiver@seul.org
- Delivered-to: or-cvs-outgoing@seul.org
- Delivered-to: or-cvs@seul.org
- Delivery-date: Wed, 19 May 2004 19:32:48 -0400
- Reply-to: or-dev@freehaven.net
- Sender: owner-or-cvs@freehaven.net
Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/home2/arma/work/onion/cvs/src/or
Modified Files:
connection.c dns.c
Log Message:
do all the heavy lifting in connection_about_to_close_connection,
not in _connection_mark_for_close
this will hopefully clean up the huge cyclical function mess
Index: connection.c
===================================================================
RCS file: /home/or/cvsroot/src/or/connection.c,v
retrieving revision 1.225
retrieving revision 1.226
diff -u -d -r1.225 -r1.226
--- connection.c 19 May 2004 20:25:44 -0000 1.225
+++ connection.c 19 May 2004 23:32:20 -0000 1.226
@@ -172,16 +172,46 @@
void connection_about_to_close_connection(connection_t *conn)
{
+
+ if(conn->type == CONN_TYPE_AP || conn->type == CONN_TYPE_EXIT) {
+ if(!conn->has_sent_end)
+ log_fn(LOG_WARN,"Edge connection hasn't sent end yet? Bug.");
+ }
+
switch(conn->type) {
case CONN_TYPE_DIR:
if(conn->purpose == DIR_PURPOSE_FETCH_RENDDESC)
rend_client_desc_fetched(conn->rend_query, 0);
break;
+ case CONN_TYPE_OR:
+ /* Remember why we're closing this connection. */
+ if (conn->state != OR_CONN_STATE_OPEN) {
+ /* XXX Nick: this still isn't right, because it might be
+ * dying even though we didn't initiate the connect. Can
+ * you look at this more? -RD */
+ if(conn->nickname)
+ rep_hist_note_connect_failed(conn->nickname, time(NULL));
+ } else if (0) { // XXX reason == CLOSE_REASON_UNUSED_OR_CONN) {
+ rep_hist_note_disconnect(conn->nickname, time(NULL));
+ } else {
+ rep_hist_note_connection_died(conn->nickname, time(NULL));
+ }
+ break;
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;
+ conn->hold_open_until_flushed = 1;
+ }
+ break;
case CONN_TYPE_EXIT:
- if(!conn->has_sent_end) {
- log_fn(LOG_WARN,"Edge connection hasn't sent end yet? Bug.");
- connection_mark_for_close(conn);
+ if (conn->state == EXIT_CONN_STATE_RESOLVING)
+ connection_dns_remove(conn);
+ break;
+ case CONN_TYPE_DNSWORKER:
+ if (conn->state == DNSWORKER_STATE_BUSY) {
+ dns_cancel_pending_resolve(conn->address);
}
break;
}
@@ -230,50 +260,6 @@
return -1;
}
- switch (conn->type)
- {
- case CONN_TYPE_OR_LISTENER:
- case CONN_TYPE_AP_LISTENER:
- case CONN_TYPE_DIR_LISTENER:
- case CONN_TYPE_CPUWORKER:
- case CONN_TYPE_DIR:
- /* No special processing needed immediately. */
- break;
- case CONN_TYPE_OR:
- /* Remember why we're closing this connection. */
- if (conn->state != OR_CONN_STATE_OPEN) {
- /* XXX Nick: this still isn't right, because it might be
- * dying even though we didn't initiate the connect. Can
- * you look at this more? -RD */
- if(conn->nickname)
- rep_hist_note_connect_failed(conn->nickname, time(NULL));
- } else if (0) { // XXX reason == CLOSE_REASON_UNUSED_OR_CONN) {
- rep_hist_note_disconnect(conn->nickname, time(NULL));
- } else {
- rep_hist_note_connection_died(conn->nickname, time(NULL));
- }
- break;
- 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;
- conn->hold_open_until_flushed = 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);
- break;
- case CONN_TYPE_DNSWORKER:
- if (conn->state == DNSWORKER_STATE_BUSY) {
- dns_cancel_pending_resolve(conn->address);
- }
- break;
- default:
- log(LOG_ERR, "Unknown connection type %d", conn->type);
- ;
- }
conn->marked_for_close = 1;
/* in case we're going to be held-open-til-flushed, reset
Index: dns.c
===================================================================
RCS file: /home/or/cvsroot/src/or/dns.c,v
retrieving revision 1.93
retrieving revision 1.94
diff -u -d -r1.93 -r1.94
--- dns.c 12 May 2004 21:12:33 -0000 1.93
+++ dns.c 19 May 2004 23:32:20 -0000 1.94
@@ -343,8 +343,10 @@
pend->conn->state = EXIT_CONN_STATE_RESOLVEFAILED;
pendconn = pend->conn; /* don't pass complex things to the
connection_mark_for_close macro */
- connection_edge_end(pendconn, END_STREAM_REASON_MISC, pendconn->cpath_layer);
- connection_mark_for_close(pendconn);
+ if(!pendconn->marked_for_close) {
+ connection_edge_end(pendconn, END_STREAM_REASON_MISC, pendconn->cpath_layer);
+ connection_mark_for_close(pendconn);
+ }
resolve->pending_connections = pend->next;
tor_free(pend);
}