mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2025-02-25 15:10:48 +01:00
Consistently allow policy alloc_cmux_data() and alloc_circ_data() functions to return NULL if the policy does not use this in circuitmux.c
This commit is contained in:
parent
86d9d85dfc
commit
debef8f0cd
1 changed files with 14 additions and 21 deletions
|
@ -293,7 +293,6 @@ circuitmux_detach_all_circuits(circuitmux_t *cmux)
|
||||||
* free it
|
* free it
|
||||||
*/
|
*/
|
||||||
tor_assert(cmux->policy);
|
tor_assert(cmux->policy);
|
||||||
tor_assert(cmux->policy_data);
|
|
||||||
tor_assert(cmux->policy->free_circ_data);
|
tor_assert(cmux->policy->free_circ_data);
|
||||||
/* Call free_circ_data() */
|
/* Call free_circ_data() */
|
||||||
cmux->policy->free_circ_data(cmux,
|
cmux->policy->free_circ_data(cmux,
|
||||||
|
@ -805,8 +804,10 @@ circuitmux_attach_circuit(circuitmux_t *cmux, circuit_t *circ,
|
||||||
hashent->muxinfo.cell_count = cell_count;
|
hashent->muxinfo.cell_count = cell_count;
|
||||||
hashent->muxinfo.direction = direction;
|
hashent->muxinfo.direction = direction;
|
||||||
/* Allocate policy specific circuit data if we need it */
|
/* Allocate policy specific circuit data if we need it */
|
||||||
if (cmux->policy && cmux->policy_data &&
|
if (cmux->policy && cmux->policy->alloc_circ_data) {
|
||||||
cmux->policy->alloc_circ_data) {
|
/* Assert that we have the means to free policy-specific data */
|
||||||
|
tor_assert(cmux->policy->free_circ_data);
|
||||||
|
/* Allocate it */
|
||||||
hashent->muxinfo.policy_data =
|
hashent->muxinfo.policy_data =
|
||||||
cmux->policy->alloc_circ_data(cmux,
|
cmux->policy->alloc_circ_data(cmux,
|
||||||
cmux->policy_data,
|
cmux->policy_data,
|
||||||
|
@ -898,7 +899,6 @@ circuitmux_detach_circuit(circuitmux_t *cmux, circuit_t *circ)
|
||||||
if (hashent->muxinfo.policy_data) {
|
if (hashent->muxinfo.policy_data) {
|
||||||
/* If we have policy data, assert that we have the means to free it */
|
/* If we have policy data, assert that we have the means to free it */
|
||||||
tor_assert(cmux->policy);
|
tor_assert(cmux->policy);
|
||||||
tor_assert(cmux->policy_data);
|
|
||||||
tor_assert(cmux->policy->free_circ_data);
|
tor_assert(cmux->policy->free_circ_data);
|
||||||
/* Call free_circ_data() */
|
/* Call free_circ_data() */
|
||||||
cmux->policy->free_circ_data(cmux,
|
cmux->policy->free_circ_data(cmux,
|
||||||
|
@ -997,16 +997,14 @@ circuitmux_make_circuit_active(circuitmux_t *cmux, circuit_t *circ,
|
||||||
|
|
||||||
/* Policy-specific notification */
|
/* Policy-specific notification */
|
||||||
if (cmux->policy &&
|
if (cmux->policy &&
|
||||||
cmux->policy->notify_circ_active &&
|
cmux->policy->notify_circ_active) {
|
||||||
cmux->policy_data) {
|
|
||||||
/* Okay, we need to check the circuit for policy data now */
|
/* Okay, we need to check the circuit for policy data now */
|
||||||
hashent = circuitmux_find_map_entry(cmux, circ);
|
hashent = circuitmux_find_map_entry(cmux, circ);
|
||||||
/* We should have found something */
|
/* We should have found something */
|
||||||
tor_assert(hashent);
|
tor_assert(hashent);
|
||||||
/* Check for policy data for the circuit and notify */
|
/* Notify */
|
||||||
if (hashent->muxinfo.policy_data)
|
cmux->policy->notify_circ_active(cmux, cmux->policy_data,
|
||||||
cmux->policy->notify_circ_active(cmux, cmux->policy_data,
|
circ, hashent->muxinfo.policy_data);
|
||||||
circ, hashent->muxinfo.policy_data);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1106,16 +1104,14 @@ circuitmux_make_circuit_inactive(circuitmux_t *cmux, circuit_t *circ,
|
||||||
|
|
||||||
/* Policy-specific notification */
|
/* Policy-specific notification */
|
||||||
if (cmux->policy &&
|
if (cmux->policy &&
|
||||||
cmux->policy->notify_circ_inactive &&
|
cmux->policy->notify_circ_inactive) {
|
||||||
cmux->policy_data) {
|
|
||||||
/* Okay, we need to check the circuit for policy data now */
|
/* Okay, we need to check the circuit for policy data now */
|
||||||
hashent = circuitmux_find_map_entry(cmux, circ);
|
hashent = circuitmux_find_map_entry(cmux, circ);
|
||||||
/* We should have found something */
|
/* We should have found something */
|
||||||
tor_assert(hashent);
|
tor_assert(hashent);
|
||||||
/* Check for policy data for the circuit and notify */
|
/* Notify */
|
||||||
if (hashent->muxinfo.policy_data)
|
cmux->policy->notify_circ_inactive(cmux, cmux->policy_data,
|
||||||
cmux->policy->notify_circ_inactive(cmux, cmux->policy_data,
|
circ, hashent->muxinfo.policy_data);
|
||||||
circ, hashent->muxinfo.policy_data);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1153,11 +1149,8 @@ circuitmux_set_num_cells(circuitmux_t *cmux, circuit_t *circ,
|
||||||
cmux->n_cells += n_cells;
|
cmux->n_cells += n_cells;
|
||||||
|
|
||||||
/* Do we need to notify a cmux policy? */
|
/* Do we need to notify a cmux policy? */
|
||||||
if (cmux->policy && cmux->policy_data &&
|
if (cmux->policy && cmux->policy->notify_set_n_cells) {
|
||||||
cmux->policy->notify_set_n_cells) {
|
/* Call notify_set_n_cells */
|
||||||
/* Yeah; assert that we have circuit policy data */
|
|
||||||
tor_assert(hashent->muxinfo.policy_data);
|
|
||||||
/* ... and call notify_set_n_cells */
|
|
||||||
cmux->policy->notify_set_n_cells(cmux,
|
cmux->policy->notify_set_n_cells(cmux,
|
||||||
cmux->policy_data,
|
cmux->policy_data,
|
||||||
circ,
|
circ,
|
||||||
|
|
Loading…
Add table
Reference in a new issue