[or-cvs] start tracking the "It appears I"ve already sent the end" w...
Roger Dingledine
arma at seul.org
Sun Dec 14 08:32:16 UTC 2003
Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/home2/arma/work/onion/cvs/src/or
Modified Files:
circuit.c connection.c connection_edge.c dns.c or.h
Log Message:
start tracking the 'It appears I've already sent the end' warning
Index: circuit.c
===================================================================
RCS file: /home/or/cvsroot/src/or/circuit.c,v
retrieving revision 1.115
retrieving revision 1.116
diff -u -d -r1.115 -r1.116
--- circuit.c 14 Dec 2003 04:19:12 -0000 1.115
+++ circuit.c 14 Dec 2003 08:32:13 -0000 1.116
@@ -625,7 +625,8 @@
if(!conn->has_sent_end) {
log_fn(LOG_INFO,"Edge connection hasn't sent end yet? Bug.");
- connection_edge_end(conn, END_STREAM_REASON_MISC, conn->cpath_layer);
+ if(connection_edge_end(conn, END_STREAM_REASON_MISC, conn->cpath_layer) < 0)
+ log_fn(LOG_WARN,"1: I called connection_edge_end redundantly.");
}
if(conn == circ->p_streams) {
Index: connection.c
===================================================================
RCS file: /home/or/cvsroot/src/or/connection.c,v
retrieving revision 1.139
retrieving revision 1.140
diff -u -d -r1.139 -r1.140
--- connection.c 14 Dec 2003 06:03:46 -0000 1.139
+++ connection.c 14 Dec 2003 08:32:13 -0000 1.140
@@ -655,7 +655,8 @@
if(!connection_speaks_cells(conn)) {
log_fn(LOG_INFO,"CircID %d: At an edge. Marking connection for close.",
circ_id);
- connection_edge_end(conn, END_STREAM_REASON_DESTROY, conn->cpath_layer);
+ if(connection_edge_end(conn, END_STREAM_REASON_DESTROY, conn->cpath_layer) < 0)
+ log_fn(LOG_WARN,"1: I called connection_edge_end redundantly.");
/* if they already sent a destroy, they know. XXX can just close? */
return 0;
}
Index: connection_edge.c
===================================================================
RCS file: /home/or/cvsroot/src/or/connection_edge.c,v
retrieving revision 1.74
retrieving revision 1.75
diff -u -d -r1.74 -r1.75
--- connection_edge.c 14 Dec 2003 07:50:45 -0000 1.74
+++ connection_edge.c 14 Dec 2003 08:32:14 -0000 1.75
@@ -31,7 +31,8 @@
conn->done_receiving = 1;
shutdown(conn->s, 0); /* XXX check return, refactor NM */
if (conn->done_sending) {
- connection_edge_end(conn, END_STREAM_REASON_DONE, conn->cpath_layer);
+ if(connection_edge_end(conn, END_STREAM_REASON_DONE, conn->cpath_layer) < 0)
+ log_fn(LOG_WARN,"1: I called connection_edge_end redundantly.");
} else {
connection_edge_send_command(conn, circuit_get_by_conn(conn), RELAY_COMMAND_END,
NULL, 0, conn->cpath_layer);
@@ -40,7 +41,8 @@
#else
/* eof reached, kill it. */
log_fn(LOG_INFO,"conn (fd %d) reached eof. Closing.", conn->s);
- connection_edge_end(conn, END_STREAM_REASON_DONE, conn->cpath_layer);
+ if(connection_edge_end(conn, END_STREAM_REASON_DONE, conn->cpath_layer) < 0)
+ log_fn(LOG_WARN,"2: I called connection_edge_end redundantly.");
return -1;
#endif
}
@@ -48,7 +50,8 @@
switch(conn->state) {
case AP_CONN_STATE_SOCKS_WAIT:
if(connection_ap_handshake_process_socks(conn) < 0) {
- connection_edge_end(conn, END_STREAM_REASON_MISC, conn->cpath_layer);
+ if(connection_edge_end(conn, END_STREAM_REASON_MISC, conn->cpath_layer) < 0)
+ log_fn(LOG_WARN,"3: I called connection_edge_end redundantly.");
return -1;
}
return 0;
@@ -59,7 +62,8 @@
return 0;
}
if(connection_edge_package_raw_inbuf(conn) < 0) {
- connection_edge_end(conn, END_STREAM_REASON_MISC, conn->cpath_layer);
+ if(connection_edge_end(conn, END_STREAM_REASON_MISC, conn->cpath_layer) < 0)
+ log_fn(LOG_WARN,"4: I called connection_edge_end redundantly.");
return -1;
}
return 0;
@@ -92,14 +96,14 @@
return "";
}
-void connection_edge_end(connection_t *conn, char reason, crypt_path_t *cpath_layer) {
+int connection_edge_end(connection_t *conn, char reason, crypt_path_t *cpath_layer) {
char payload[5];
int payload_len=1;
circuit_t *circ;
if(conn->has_sent_end) {
log_fn(LOG_WARN,"It appears I've already sent the end. Are you calling me twice?");
- return;
+ return -1;
}
payload[0] = reason;
@@ -117,6 +121,7 @@
conn->marked_for_close = 1;
conn->has_sent_end = 1;
+ return 0;
}
int connection_edge_send_command(connection_t *fromconn, circuit_t *circ, int relay_command,
@@ -197,7 +202,8 @@
} else {
log_fn(LOG_WARN,"Got an unexpected relay command %d, in state %d (%s). Closing.",
relay_command, conn->state, conn_state_to_string[conn->type][conn->state]);
- connection_edge_end(conn, END_STREAM_REASON_MISC, conn->cpath_layer);
+ if(connection_edge_end(conn, END_STREAM_REASON_MISC, conn->cpath_layer) < 0)
+ log_fn(LOG_WARN,"1: I called connection_edge_end redundantly.");
return -1;
}
}
@@ -219,7 +225,8 @@
if((edge_type == EDGE_AP && --layer_hint->deliver_window < 0) ||
(edge_type == EDGE_EXIT && --circ->deliver_window < 0)) {
log_fn(LOG_WARN,"(relay data) circ deliver_window below 0. Killing.");
- connection_edge_end(conn, END_STREAM_REASON_MISC, conn->cpath_layer);
+ if(connection_edge_end(conn, END_STREAM_REASON_MISC, conn->cpath_layer) < 0)
+ log_fn(LOG_WARN,"2: I called connection_edge_end redundantly.");
return -1;
}
log_fn(LOG_DEBUG,"circ deliver_window now %d.", edge_type == EDGE_AP ? layer_hint->deliver_window : circ->deliver_window);
@@ -346,7 +353,8 @@
}
if(connection_ap_handshake_socks_reply(conn, NULL, 0, 1) < 0) {
log_fn(LOG_INFO,"Writing to socks-speaking application failed. Closing.");
- connection_edge_end(conn, END_STREAM_REASON_MISC, conn->cpath_layer);
+ if(connection_edge_end(conn, END_STREAM_REASON_MISC, conn->cpath_layer) < 0)
+ log_fn(LOG_WARN,"3: I called connection_edge_end redundantly.");
}
return 0;
case RELAY_COMMAND_SENDME:
@@ -775,7 +783,8 @@
return 0;
case -1: /* resolve failed */
log_fn(LOG_INFO,"Resolve failed (%s).", n_stream->address);
- connection_edge_end(n_stream, END_STREAM_REASON_RESOLVEFAILED, NULL);
+ if(connection_edge_end(n_stream, END_STREAM_REASON_RESOLVEFAILED, NULL) < 0)
+ log_fn(LOG_WARN,"1: I called connection_edge_end redundantly.");
/* case 0, resolve added to pending list */
}
return 0;
@@ -786,13 +795,15 @@
if(router_compare_to_my_exit_policy(conn) < 0) {
log_fn(LOG_INFO,"%s:%d failed exit policy. Closing.", conn->address, conn->port);
- connection_edge_end(conn, END_STREAM_REASON_EXITPOLICY, NULL);
+ if(connection_edge_end(conn, END_STREAM_REASON_EXITPOLICY, NULL) < 0)
+ log_fn(LOG_WARN,"1: I called connection_edge_end redundantly.");
return;
}
switch(connection_connect(conn, conn->address, conn->addr, conn->port)) {
case -1:
- connection_edge_end(conn, END_STREAM_REASON_CONNECTFAILED, NULL);
+ if(connection_edge_end(conn, END_STREAM_REASON_CONNECTFAILED, NULL) < 0)
+ log_fn(LOG_WARN,"2: I called connection_edge_end redundantly.");
return;
case 0:
connection_set_poll_socket(conn);
Index: dns.c
===================================================================
RCS file: /home/or/cvsroot/src/or/dns.c,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -d -r1.43 -r1.44
--- dns.c 14 Dec 2003 07:40:47 -0000 1.43
+++ dns.c 14 Dec 2003 08:32:14 -0000 1.44
@@ -265,7 +265,8 @@
address);
while(resolve->pending_connections) {
pend = resolve->pending_connections;
- connection_edge_end(pend->conn, END_STREAM_REASON_MISC, NULL);
+ if(connection_edge_end(pend->conn, END_STREAM_REASON_MISC, NULL) < 0)
+ log_fn(LOG_WARN,"1: I called connection_edge_end redundantly.");
resolve->pending_connections = pend->next;
free(pend);
}
@@ -327,9 +328,10 @@
while(resolve->pending_connections) {
pend = resolve->pending_connections;
pend->conn->addr = resolve->addr;
- if(resolve->state == CACHE_STATE_FAILED)
- connection_edge_end(pend->conn, END_STREAM_REASON_RESOLVEFAILED, NULL);
- else
+ if(resolve->state == CACHE_STATE_FAILED) {
+ if(connection_edge_end(pend->conn, END_STREAM_REASON_RESOLVEFAILED, NULL) < 0)
+ log_fn(LOG_WARN,"1: I called connection_edge_end redundantly.");
+ } else
connection_exit_connect(pend->conn);
resolve->pending_connections = pend->next;
free(pend);
Index: or.h
===================================================================
RCS file: /home/or/cvsroot/src/or/or.h,v
retrieving revision 1.205
retrieving revision 1.206
diff -u -d -r1.205 -r1.206
--- or.h 14 Dec 2003 07:40:47 -0000 1.205
+++ or.h 14 Dec 2003 08:32:14 -0000 1.206
@@ -618,7 +618,7 @@
/********************************* connection_edge.c ***************************/
int connection_edge_process_inbuf(connection_t *conn);
-void connection_edge_end(connection_t *conn, char reason, crypt_path_t *cpath_layer);
+int connection_edge_end(connection_t *conn, char reason, crypt_path_t *cpath_layer);
int connection_edge_send_command(connection_t *fromconn, circuit_t *circ, int relay_command,
void *payload, int payload_len, crypt_path_t *cpath_layer);
More information about the tor-commits
mailing list