[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] Add a pointer from edge connections to their corresponding ...
- To: or-cvs@xxxxxxxxxxxxx
- Subject: [or-cvs] Add a pointer from edge connections to their corresponding ...
- From: nickm@xxxxxxxx (Nick Mathewson)
- Date: Wed, 6 Apr 2005 02:13:51 -0400 (EDT)
- Delivered-to: archiver@seul.org
- Delivered-to: or-cvs-outgoing@seul.org
- Delivered-to: or-cvs@seul.org
- Delivery-date: Wed, 06 Apr 2005 02:14:16 -0400
- Reply-to: or-dev@xxxxxxxxxxxxx
- Sender: owner-or-cvs@xxxxxxxxxxxxx
Update of /home/or/cvsroot/tor/src/or
In directory moria.mit.edu:/tmp/cvs-serv6226/src/or
Modified Files:
circuitlist.c circuituse.c connection_edge.c dns.c or.h
Log Message:
Add a pointer from edge connections to their corresponding circuit (ulp!); add some debugging sanity-checking for cirid_orconn_map stuff
Index: circuitlist.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/circuitlist.c,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -d -r1.38 -r1.39
--- circuitlist.c 6 Apr 2005 05:33:32 -0000 1.38
+++ circuitlist.c 6 Apr 2005 06:13:48 -0000 1.39
@@ -32,6 +32,7 @@
/********* END VARIABLES ************/
+/** DOCDOC This whole section */
struct orconn_circid_circuit_map_t {
SPLAY_ENTRY(orconn_circid_circuit_map_t) node;
connection_t *or_conn;
@@ -298,8 +299,60 @@
found = SPLAY_FIND(orconn_circid_tree, &orconn_circid_circuit_map, &search);
if (found && found->circuit && !found->circuit->marked_for_close)
return found->circuit;
- else
+
+ /* The rest of this can be replaced with
+ "return NULL;" once we believe the code works. */
+
+ {
+ circuit_t *circ;
+ for (circ=global_circuitlist;circ;circ = circ->next) {
+ if (circ->marked_for_close)
+ continue;
+
+ if (circ->p_conn == conn && circ->p_circ_id == circ_id) {
+ log_fn(LOG_WARN, "circuit matches p_conn, but not in tree (Bug!)");
+ return circ;
+ }
+ if (circ->n_conn == conn && circ->n_circ_id == circ_id) {
+ log_fn(LOG_WARN, "circuit matches n_conn, but not in tree (Bug!)");
+ return circ;
+ }
+ }
return NULL;
+ }
+
+}
+
+/** DOCDOC */
+circuit_t *circuit_get_by_stream(connection_t *conn)
+{
+ circuit_t *circ;
+ connection_t *tmpconn;
+ tor_assert(CONN_IS_EDGE(conn));
+
+ if (! conn->on_circuit) {
+ /* return NULL; */
+ circ = circuit_get_by_conn(conn);
+ if (circ) {
+ log_fn(LOG_WARN, "BUG: conn->on_circuit==NULL, but there was in fact a circuit there. ");
+ }
+ return circ;
+ }
+
+ circ = conn->on_circuit;
+ /* All this stuff here is sanity-checking. */
+ tor_assert(circ->magic == CIRCUIT_MAGIC);
+ for (tmpconn = circ->p_streams; tmpconn; tmpconn=tmpconn->next_stream)
+ if (tmpconn == conn)
+ return circ;
+ for (tmpconn = circ->n_streams; tmpconn; tmpconn=tmpconn->next_stream)
+ if (tmpconn == conn)
+ return circ;
+ for (tmpconn = circ->resolving_streams; tmpconn; tmpconn=tmpconn->next_stream)
+ if (tmpconn == conn)
+ return circ;
+
+ tor_assert(0);
}
/** Return a circ such that circ is attached to <b>conn</b>, either as
@@ -505,6 +558,7 @@
conn->has_sent_end = 1; /* we're closing the circuit, nothing to send to */
connection_mark_for_close(conn);
}
+ conn->on_circuit = NULL;
}
if (circ->p_conn)
connection_send_destroy(circ->p_circ_id, circ->p_conn);
Index: circuituse.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/circuituse.c,v
retrieving revision 1.66
retrieving revision 1.67
diff -u -d -r1.66 -r1.67
--- circuituse.c 6 Apr 2005 05:33:32 -0000 1.66
+++ circuituse.c 6 Apr 2005 06:13:48 -0000 1.67
@@ -417,6 +417,7 @@
tor_assert(conn);
conn->cpath_layer = NULL; /* make sure we don't keep a stale pointer */
+ conn->on_circuit = NULL;
if (conn == circ->p_streams) {
circ->p_streams = conn->next_stream;
@@ -923,6 +924,7 @@
log_fn(LOG_DEBUG,"attaching new conn to circ. n_circ_id %d.", circ->n_circ_id);
apconn->timestamp_lastread = time(NULL); /* reset it, so we can measure circ timeouts */
apconn->next_stream = circ->p_streams;
+ apconn->on_circuit = circ;
/* assert_connection_ok(conn, time(NULL)); */
circ->p_streams = apconn;
Index: connection_edge.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/connection_edge.c,v
retrieving revision 1.317
retrieving revision 1.318
diff -u -d -r1.317 -r1.318
--- connection_edge.c 3 Apr 2005 05:22:33 -0000 1.317
+++ connection_edge.c 6 Apr 2005 06:13:48 -0000 1.318
@@ -142,18 +142,19 @@
int connection_edge_destroy(uint16_t circ_id, connection_t *conn) {
tor_assert(CONN_IS_EDGE(conn));
- if (conn->marked_for_close)
- return 0; /* already marked; probably got an 'end' */
- log_fn(LOG_INFO,"CircID %d: At an edge. Marking connection for close.",
- circ_id);
- if (conn->type == CONN_TYPE_AP) {
- connection_mark_unattached_ap(conn, END_STREAM_REASON_DESTROY);
- } else {
- conn->has_sent_end = 1; /* we're closing the circuit, nothing to send to */
- connection_mark_for_close(conn);
- conn->hold_open_until_flushed = 1;
+ if (!conn->marked_for_close) {
+ log_fn(LOG_INFO,"CircID %d: At an edge. Marking connection for close.",
+ circ_id);
+ if (conn->type == CONN_TYPE_AP) {
+ connection_mark_unattached_ap(conn, END_STREAM_REASON_DESTROY);
+ } else {
+ conn->has_sent_end = 1; /* we're closing the circuit, nothing to send to */
+ connection_mark_for_close(conn);
+ conn->hold_open_until_flushed = 1;
+ }
}
conn->cpath_layer = NULL;
+ conn->on_circuit = NULL;
return 0;
}
@@ -1368,6 +1369,7 @@
/* add it into the linked list of n_streams on this circuit */
n_stream->next_stream = circ->n_streams;
+ n_stream->on_circuit = circ;
circ->n_streams = n_stream;
assert_circuit_ok(circ);
@@ -1392,6 +1394,7 @@
/* add it into the linked list of n_streams on this circuit */
n_stream->next_stream = circ->n_streams;
+ n_stream->on_circuit = circ;
circ->n_streams = n_stream;
assert_circuit_ok(circ);
@@ -1403,6 +1406,7 @@
case 0: /* resolve added to pending list */
/* add it into the linked list of resolving_streams on this circuit */
n_stream->next_stream = circ->resolving_streams;
+ n_stream->on_circuit = circ;
circ->resolving_streams = n_stream;
assert_circuit_ok(circ);
;
@@ -1447,6 +1451,7 @@
return 0;
case 0: /* resolve added to pending list */
dummy_conn->next_stream = circ->resolving_streams;
+ dummy_conn->on_circuit = circ;
circ->resolving_streams = dummy_conn;
assert_circuit_ok(circ);
break;
Index: dns.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/dns.c,v
retrieving revision 1.144
retrieving revision 1.145
diff -u -d -r1.144 -r1.145
--- dns.c 6 Apr 2005 05:44:05 -0000 1.144
+++ dns.c 6 Apr 2005 06:13:49 -0000 1.145
@@ -571,6 +571,7 @@
circuit_detach_stream(circ, pend->conn);
/* and link it to n_streams */
pend->conn->next_stream = circ->n_streams;
+ pend->conn->on_circuit = circ;
circ->n_streams = pend->conn;
connection_exit_connect(pend->conn);
Index: or.h
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/or.h,v
retrieving revision 1.585
retrieving revision 1.586
diff -u -d -r1.585 -r1.586
--- or.h 6 Apr 2005 05:33:32 -0000 1.585
+++ or.h 6 Apr 2005 06:13:49 -0000 1.586
@@ -629,6 +629,7 @@
int done_receiving; /**< For half-open connections; not used currently. */
char has_sent_end; /**< For debugging: set once we've set the stream end,
and check in circuit_about_to_close_connection(). */
+ struct circuit_t *on_circuit; /**< DOCDOC */
/* Used only by AP connections */
socks_request_t *socks_request; /**< SOCKS structure describing request (AP