aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2006-12-04 05:55:40 +0000
committerNick Mathewson <nickm@torproject.org>2006-12-04 05:55:40 +0000
commita91c12f2e7adfb179f5a8034c1ed1265b8fe8a74 (patch)
tree39f70a5f2b05376ad88bffc026a148626f330280
parentf90cd5bfc0267afd61da2414fa9cc2605ca997b4 (diff)
downloadtor-a91c12f2e7adfb179f5a8034c1ed1265b8fe8a74.tar
tor-a91c12f2e7adfb179f5a8034c1ed1265b8fe8a74.tar.gz
r9855@Kushana: nickm | 2006-12-04 00:55:09 -0500
Merge circuit_about_to_close_connection and connection_about_to_close_connection. svn:r9021
-rw-r--r--ChangeLog5
-rw-r--r--src/or/circuituse.c44
-rw-r--r--src/or/connection.c18
-rw-r--r--src/or/main.c1
-rw-r--r--src/or/or.h4
5 files changed, 21 insertions, 51 deletions
diff --git a/ChangeLog b/ChangeLog
index 08e273602..3b548562b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,11 @@ Changes in version 0.1.2.5-xxxx - 200?-??-??
- Fix a bug when a PF socket is first used. (Patch from Fabian
Keil)
+ o Controller bugfixes:
+ - Report the circuit number correctly in STREAM CLOSED events. (Bug
+ reported by Mike Perry)
+
+
Changes in version 0.1.2.4-alpha - 2006-12-03
o Major features:
- Add support for using natd; this allows FreeBSDs earlier than
diff --git a/src/or/circuituse.c b/src/or/circuituse.c
index 84b642fbe..bc7d08736 100644
--- a/src/or/circuituse.c
+++ b/src/or/circuituse.c
@@ -518,50 +518,6 @@ circuit_detach_stream(circuit_t *circ, edge_connection_t *conn)
tor_assert(0); /* should never get here */
}
-/** Notify the global circuit list that <b>conn</b> is about to be
- * removed and then freed.
- *
- * If it's an OR conn, then mark-for-close all the circuits that use
- * that conn.
- *
- * If it's an edge conn, then detach it from its circ, so we don't
- * try to reference it later.
- */
-void
-circuit_about_to_close_connection(connection_t *conn)
-{
- /* currently, we assume it's too late to flush conn's buf here.
- * down the road, maybe we'll consider that eof doesn't mean can't-write
- */
- switch (conn->type) {
- case CONN_TYPE_OR: {
- if (!connection_state_is_open(conn)) {
- /* Inform any pending (not attached) circs that they should
- * give up. */
- circuit_n_conn_done(TO_OR_CONN(conn), 0);
- }
- /* Now close all the attached circuits on it. */
- circuit_unlink_all_from_or_conn(TO_OR_CONN(conn),
- END_CIRC_REASON_OR_CONN_CLOSED);
- return;
- }
- case CONN_TYPE_AP:
- case CONN_TYPE_EXIT: {
- circuit_t *circ;
- /* It's an edge conn. Need to remove it from the linked list of
- * conn's for this circuit. Confirm that 'end' relay command has
- * been sent. But don't kill the circuit.
- */
-
- circ = circuit_get_by_edge_conn(TO_EDGE_CONN(conn));
- if (!circ)
- return;
-
- circuit_detach_stream(circ, TO_EDGE_CONN(conn));
- }
- } /* end switch */
-}
-
/** Find each circuit that has been unused for too long, or dirty
* for too long and has no streax=ms on it: mark it for close.
*/
diff --git a/src/or/connection.c b/src/or/connection.c
index 582e6e1d6..1b733f58b 100644
--- a/src/or/connection.c
+++ b/src/or/connection.c
@@ -393,6 +393,7 @@ connection_free_all(void)
* - Exit conns need to call connection_dns_remove() if necessary.
* - AP and Exit conns need to send an end cell if they can.
* - DNS conns need to fail any resolves that are pending on them.
+ * - OR and edge connections need to be unlinked from circuits.
*/
void
connection_about_to_close_connection(connection_t *conn)
@@ -436,6 +437,9 @@ connection_about_to_close_connection(connection_t *conn)
router_set_status(or_conn->identity_digest, 0);
control_event_or_conn_status(or_conn, OR_CONN_EVENT_FAILED);
}
+ /* Inform any pending (not attached) circs that they should
+ * give up. */
+ circuit_n_conn_done(TO_OR_CONN(conn), 0);
} else if (conn->hold_open_until_flushed) {
/* XXXX009 We used to have an arg that told us whether we closed the
* connection on purpose or not. Can we use hold_open_until_flushed
@@ -452,6 +456,9 @@ connection_about_to_close_connection(connection_t *conn)
rep_hist_note_connection_died(or_conn->identity_digest, now);
control_event_or_conn_status(or_conn, OR_CONN_EVENT_CLOSED);
}
+ /* Now close all the attached circuits on it. */
+ circuit_unlink_all_from_or_conn(TO_OR_CONN(conn),
+ END_CIRC_REASON_OR_CONN_CLOSED);
break;
case CONN_TYPE_AP:
edge_conn = TO_EDGE_CONN(conn);
@@ -463,20 +470,23 @@ connection_about_to_close_connection(connection_t *conn)
conn->marked_for_close_file, conn->marked_for_close);
}
if (!edge_conn->end_reason) {
- // XXXX Disable this before 0.1.2.x-final ships.
+ // XXXX012 Disable this before 0.1.2.x-final ships.
log_warn(LD_BUG,"Bug: Closing stream (marked at %s:%d) without having"
" set end_reason. Please tell Nick.",
conn->marked_for_close_file, conn->marked_for_close);
}
control_event_stream_status(edge_conn, STREAM_EVENT_CLOSED,
edge_conn->end_reason);
+ circ = circuit_get_by_edge_conn(edge_conn);
+ if (circ)
+ circuit_detach_stream(circ, edge_conn);
break;
case CONN_TYPE_EXIT:
edge_conn = TO_EDGE_CONN(conn);
+ circ = circuit_get_by_edge_conn(edge_conn);
+ if (circ)
+ circuit_detach_stream(circ, edge_conn);
if (conn->state == EXIT_CONN_STATE_RESOLVING) {
- circ = circuit_get_by_edge_conn(edge_conn);
- if (circ)
- circuit_detach_stream(circ, edge_conn);
connection_dns_remove(edge_conn);
}
break;
diff --git a/src/or/main.c b/src/or/main.c
index fa97e4122..e8140683d 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -208,7 +208,6 @@ connection_remove(connection_t *conn)
static void
connection_unlink(connection_t *conn, int remove)
{
- circuit_about_to_close_connection(conn);
connection_about_to_close_connection(conn);
if (remove) {
connection_remove(conn);
diff --git a/src/or/or.h b/src/or/or.h
index 214c53968..59d3e005a 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -673,7 +673,8 @@ typedef struct connection_t {
* conn? */
unsigned edge_has_sent_end:1; /**< For debugging; only used on edge
* connections. Set once we've set the stream end,
- * and check in circuit_about_to_close_connection(). */
+ * and check in connection_about_to_close_connection().
+ */
/** Used for OR conns that shouldn't get any new circs attached to them. */
unsigned int or_is_obsolete:1;
/** For AP connections only. If 1, and we fail to reach the chosen exit,
@@ -1835,7 +1836,6 @@ int circuit_stream_is_being_handled(edge_connection_t *conn, uint16_t port,
int min);
void circuit_build_needed_circs(time_t now);
void circuit_detach_stream(circuit_t *circ, edge_connection_t *conn);
-void circuit_about_to_close_connection(connection_t *conn);
void reset_bandwidth_test(void);
int circuit_enough_testing_circs(void);