summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2006-10-13 05:27:59 +0000
committerNick Mathewson <nickm@torproject.org>2006-10-13 05:27:59 +0000
commit78043b847822d122e38942b2fe71e0840235a169 (patch)
tree626f3c10c95da9428bcf8be636b5e19afc28bccd
parentff487020aba23c17845a57f4f8ad1c4a72b9a1f2 (diff)
downloadtor-78043b847822d122e38942b2fe71e0840235a169.tar.gz
tor-78043b847822d122e38942b2fe71e0840235a169.zip
r9017@totoro: nickm | 2006-10-13 01:27:33 -0400
Second patch to work on circuit close reasons from Mike Perry. Disabled partially; see comment. Whitespace cleaned up. svn:r8699
-rw-r--r--src/or/command.c13
-rw-r--r--src/or/control.c4
-rw-r--r--src/or/relay.c2
3 files changed, 16 insertions, 3 deletions
diff --git a/src/or/command.c b/src/or/command.c
index 27779daeb6..8a45ff46b5 100644
--- a/src/or/command.c
+++ b/src/or/command.c
@@ -378,6 +378,19 @@ command_process_destroy_cell(cell_t *cell, or_connection_t *conn)
} else { /* the destroy came from ahead */
circuit_set_n_circid_orconn(circ, 0, NULL);
if (CIRCUIT_IS_ORIGIN(circ)) {
+ /* Prevent arbitrary destroys from going unnoticed by controller */
+ /* XXXX Not quite right; what we want is to tell the controller the
+ * exact reason that we were asked to close, but tell it that we
+ * closed because we were asked. Anything else is not accurate.
+ * OR_CONN_CLOSED is certainly wrong, since a destroy doesn't mean
+ * that the underlying OR connection got closed. -NM */
+#if 0
+ if (reason == END_CIRC_AT_ORIGIN ||
+ reason == END_CIRC_REASON_NONE ||
+ reason == END_CIRC_REASON_REQUESTED) {
+ reason = END_CIRC_REASON_OR_CONN_CLOSED;
+ }
+#endif
circuit_mark_for_close(circ, reason);
} else {
char payload[1];
diff --git a/src/or/control.c b/src/or/control.c
index a9f0c364f4..66477018f9 100644
--- a/src/or/control.c
+++ b/src/or/control.c
@@ -2370,7 +2370,7 @@ handle_control_closecircuit(control_connection_t *conn, uint32_t len,
}
if (!safe || !circ->p_streams) {
- circuit_mark_for_close(TO_CIRCUIT(circ), END_CIRC_REASON_NONE);
+ circuit_mark_for_close(TO_CIRCUIT(circ), END_CIRC_REASON_REQUESTED);
}
send_control_done(conn);
@@ -2990,7 +2990,7 @@ orconn_target_get_name(int long_names,
name[0] = '$';
base16_encode(name+1, len-1, conn->identity_digest,
DIGEST_LEN);
- } else {
+ } else {
tor_snprintf(name, len, "%s:%d",
conn->_base.address, conn->_base.port);
}
diff --git a/src/or/relay.c b/src/or/relay.c
index c7409c9a57..503b60180c 100644
--- a/src/or/relay.c
+++ b/src/or/relay.c
@@ -158,7 +158,7 @@ circuit_receive_relay_cell(cell_t *cell, circuit_t *circ, int cell_direction)
if (relay_crypt(circ, cell, cell_direction, &layer_hint, &recognized) < 0) {
log_warn(LD_BUG,"relay crypt failed. Dropping connection.");
- return -1;
+ return -END_CIRC_REASON_INTERNAL;
}
if (recognized) {