diff options
author | Robert Ransom <rransom.8774@gmail.com> | 2011-11-24 06:54:55 -0800 |
---|---|---|
committer | Robert Ransom <rransom.8774@gmail.com> | 2011-11-24 06:54:55 -0800 |
commit | 296b8d0b10cc8e5d42c88284ed1b37b510f4a5bc (patch) | |
tree | d049a6535965b11e54dc743aa20174cf79a02bb9 /src/or/circuituse.c | |
parent | 104c50fedb1b9217fbb2a8cc5fcf9ec9c9be2674 (diff) | |
download | tor-296b8d0b10cc8e5d42c88284ed1b37b510f4a5bc.tar.gz tor-296b8d0b10cc8e5d42c88284ed1b37b510f4a5bc.zip |
Add CIRC2 control-port event, and send it when a circ's purpose changes
Diffstat (limited to 'src/or/circuituse.c')
-rw-r--r-- | src/or/circuituse.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/or/circuituse.c b/src/or/circuituse.c index 46c0b8a0fa..1b91100649 100644 --- a/src/or/circuituse.c +++ b/src/or/circuituse.c @@ -1929,6 +1929,7 @@ connection_ap_handshake_attach_circuit(entry_connection_t *conn) void circuit_change_purpose(circuit_t *circ, uint8_t new_purpose) { + uint8_t old_purpose; /* Don't allow an OR circ to become an origin circ or vice versa. */ tor_assert(!!(CIRCUIT_IS_ORIGIN(circ)) == !!(CIRCUIT_PURPOSE_IS_ORIGIN(new_purpose))); @@ -1936,21 +1937,28 @@ circuit_change_purpose(circuit_t *circ, uint8_t new_purpose) if (circ->purpose == new_purpose) return; if (CIRCUIT_IS_ORIGIN(circ)) { - char old_purpose[80] = ""; + char old_purpose_desc[80] = ""; - strncpy(old_purpose, circuit_purpose_to_string(circ->purpose), 80-1); - old_purpose[80-1] = '\0'; + strncpy(old_purpose_desc, circuit_purpose_to_string(circ->purpose), 80-1); + old_purpose_desc[80-1] = '\0'; log_debug(LD_CIRC, "changing purpose of origin circ %d " "from \"%s\" (%d) to \"%s\" (%d)", TO_ORIGIN_CIRCUIT(circ)->global_identifier, - old_purpose, + old_purpose_desc, circ->purpose, circuit_purpose_to_string(new_purpose), new_purpose); } + old_purpose = circ->purpose; circ->purpose = new_purpose; + + if (CIRCUIT_IS_ORIGIN(circ)) { + control_event_circuit_status_2(TO_ORIGIN_CIRCUIT(circ), + CIRC2_EVENT_PURPOSE_CHANGED, + (int)old_purpose, NULL); + } } |