aboutsummaryrefslogtreecommitdiff
path: root/src/core/or/circuitlist.c
diff options
context:
space:
mode:
authorDavid Goulet <dgoulet@torproject.org>2019-06-11 11:59:39 -0400
committerDavid Goulet <dgoulet@torproject.org>2019-06-11 11:59:39 -0400
commitf7e8b3b68c8e2cecfc7ff4072e9f00d316aaba4f (patch)
treeddd7cd4b63c03d0c35b7e9063b8e40ea2bb065d6 /src/core/or/circuitlist.c
parent8e112cecd8cf944e095304257563415e60891780 (diff)
parent5f5f6bb8fb68d171a39eb1e5c6e6649087ec551d (diff)
downloadtor-f7e8b3b68c8e2cecfc7ff4072e9f00d316aaba4f.tar.gz
tor-f7e8b3b68c8e2cecfc7ff4072e9f00d316aaba4f.zip
Merge branch 'tor-github/pr/1040'
Diffstat (limited to 'src/core/or/circuitlist.c')
-rw-r--r--src/core/or/circuitlist.c33
1 files changed, 16 insertions, 17 deletions
diff --git a/src/core/or/circuitlist.c b/src/core/or/circuitlist.c
index ebbe7f0824..9ee9f93c99 100644
--- a/src/core/or/circuitlist.c
+++ b/src/core/or/circuitlist.c
@@ -496,17 +496,16 @@ int
circuit_event_status(origin_circuit_t *circ, circuit_status_event_t tp,
int reason_code)
{
- ocirc_event_msg_t msg;
+ ocirc_cevent_msg_t *msg = tor_malloc(sizeof(*msg));
tor_assert(circ);
- msg.type = OCIRC_MSGTYPE_CEVENT;
- msg.u.cevent.gid = circ->global_identifier;
- msg.u.cevent.evtype = tp;
- msg.u.cevent.reason = reason_code;
- msg.u.cevent.onehop = circ->build_state->onehop_tunnel;
+ msg->gid = circ->global_identifier;
+ msg->evtype = tp;
+ msg->reason = reason_code;
+ msg->onehop = circ->build_state->onehop_tunnel;
- ocirc_event_publish(&msg);
+ ocirc_cevent_publish(msg);
return control_event_circuit_status(circ, tp, reason_code);
}
@@ -514,26 +513,25 @@ circuit_event_status(origin_circuit_t *circ, circuit_status_event_t tp,
* Helper function to publish a state change message
*
* circuit_set_state() calls this to notify subscribers about a change
- * of the state of an origin circuit.
+ * of the state of an origin circuit. @a circ must be an origin
+ * circuit.
**/
static void
circuit_state_publish(const circuit_t *circ)
{
- ocirc_event_msg_t msg;
+ ocirc_state_msg_t *msg = tor_malloc(sizeof(*msg));
const origin_circuit_t *ocirc;
- if (!CIRCUIT_IS_ORIGIN(circ))
- return;
+ tor_assert(CIRCUIT_IS_ORIGIN(circ));
ocirc = CONST_TO_ORIGIN_CIRCUIT(circ);
/* Only inbound OR circuits can be in this state, not origin circuits. */
tor_assert(circ->state != CIRCUIT_STATE_ONIONSKIN_PENDING);
- msg.type = OCIRC_MSGTYPE_STATE;
- msg.u.state.gid = ocirc->global_identifier;
- msg.u.state.state = circ->state;
- msg.u.state.onehop = ocirc->build_state->onehop_tunnel;
+ msg->gid = ocirc->global_identifier;
+ msg->state = circ->state;
+ msg->onehop = ocirc->build_state->onehop_tunnel;
- ocirc_event_publish(&msg);
+ ocirc_state_publish(msg);
}
/** Change the state of <b>circ</b> to <b>state</b>, adding it to or removing
@@ -565,7 +563,8 @@ circuit_set_state(circuit_t *circ, uint8_t state)
if (state == CIRCUIT_STATE_GUARD_WAIT || state == CIRCUIT_STATE_OPEN)
tor_assert(!circ->n_chan_create_cell);
circ->state = state;
- circuit_state_publish(circ);
+ if (CIRCUIT_IS_ORIGIN(circ))
+ circuit_state_publish(circ);
}
/** Append to <b>out</b> all circuits in state CHAN_WAIT waiting for