summaryrefslogtreecommitdiff
path: root/src/or/circuituse.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/or/circuituse.c')
-rw-r--r--src/or/circuituse.c16
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);
+ }
}