Skip to content

Commit

Permalink
circ: Remove n_mux and p_mux members
Browse files Browse the repository at this point in the history
They are simply not used apart from assigning a pointer and asserting on the
pointer depending on the cell direction.

Closes #29196.

Signed-off-by: David Goulet <dgoulet@torproject.org>
  • Loading branch information
dgoulet-tor committed Jan 29, 2019
1 parent d9010c5 commit a1a9756
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 45 deletions.
6 changes: 0 additions & 6 deletions src/core/or/circuit_st.h
Expand Up @@ -66,12 +66,6 @@ struct circuit_t {
*/
circid_t n_circ_id;

/**
* Circuit mux associated with n_chan to which this circuit is attached;
* NULL if we have no n_chan.
*/
circuitmux_t *n_mux;

/** Queue of cells waiting to be transmitted on n_chan */
cell_queue_t n_chan_cells;

Expand Down
4 changes: 0 additions & 4 deletions src/core/or/circuitlist.c
Expand Up @@ -2433,13 +2433,9 @@ marked_circuit_free_cells(circuit_t *circ)
return;
}
cell_queue_clear(&circ->n_chan_cells);
if (circ->n_mux)
circuitmux_clear_num_cells(circ->n_mux, circ);
if (! CIRCUIT_IS_ORIGIN(circ)) {
or_circuit_t *orcirc = TO_OR_CIRCUIT(circ);
cell_queue_clear(&orcirc->p_chan_cells);
if (orcirc->p_mux)
circuitmux_clear_num_cells(orcirc->p_mux, circ);
}
}

Expand Down
29 changes: 1 addition & 28 deletions src/core/or/circuitmux.c
Expand Up @@ -294,9 +294,6 @@ circuitmux_detach_all_circuits(circuitmux_t *cmux, smartlist_t *detached_out)
circuitmux_make_circuit_inactive(cmux, circ);
}

/* Clear n_mux */
circ->n_mux = NULL;

if (detached_out)
smartlist_add(detached_out, circ);
} else if (circ->magic == OR_CIRCUIT_MAGIC) {
Expand All @@ -309,12 +306,6 @@ circuitmux_detach_all_circuits(circuitmux_t *cmux, smartlist_t *detached_out)
circuitmux_make_circuit_inactive(cmux, circ);
}

/*
* It has a sensible p_chan and direction == CELL_DIRECTION_IN,
* so clear p_mux.
*/
TO_OR_CIRCUIT(circ)->p_mux = NULL;

if (detached_out)
smartlist_add(detached_out, circ);
} else {
Expand Down Expand Up @@ -836,18 +827,14 @@ circuitmux_attach_circuit,(circuitmux_t *cmux, circuit_t *circ,
*/
log_info(LD_CIRC,
"Circuit %u on channel %"PRIu64 " was already attached to "
"cmux %p (trying to attach to %p)",
"(trying to attach to %p)",
(unsigned)circ_id, (channel_id),
((direction == CELL_DIRECTION_OUT) ?
circ->n_mux : TO_OR_CIRCUIT(circ)->p_mux),
cmux);

/*
* The mux pointer on this circuit and the direction in result should
* match; otherwise assert.
*/
if (direction == CELL_DIRECTION_OUT) tor_assert(circ->n_mux == cmux);
else tor_assert(TO_OR_CIRCUIT(circ)->p_mux == cmux);
tor_assert(hashent->muxinfo.direction == direction);

/*
Expand All @@ -872,13 +859,6 @@ circuitmux_attach_circuit,(circuitmux_t *cmux, circuit_t *circ,
"Attaching circuit %u on channel %"PRIu64 " to cmux %p",
(unsigned)circ_id, (channel_id), cmux);

/*
* Assert that the circuit doesn't already have a mux for this
* direction.
*/
if (direction == CELL_DIRECTION_OUT) tor_assert(circ->n_mux == NULL);
else tor_assert(TO_OR_CIRCUIT(circ)->p_mux == NULL);

/* Insert it in the map */
hashent = tor_malloc_zero(sizeof(*hashent));
hashent->chan_id = channel_id;
Expand All @@ -902,10 +882,6 @@ circuitmux_attach_circuit,(circuitmux_t *cmux, circuit_t *circ,
HT_INSERT(chanid_circid_muxinfo_map, cmux->chanid_circid_map,
hashent);

/* Set the circuit's mux for this direction */
if (direction == CELL_DIRECTION_OUT) circ->n_mux = cmux;
else TO_OR_CIRCUIT(circ)->p_mux = cmux;

/* Update counters */
++(cmux->n_circuits);
if (cell_count > 0) {
Expand Down Expand Up @@ -993,9 +969,6 @@ circuitmux_detach_circuit,(circuitmux_t *cmux, circuit_t *circ))

/* Consistency check: the direction must match the direction searched */
tor_assert(last_searched_direction == hashent->muxinfo.direction);
/* Clear the circuit's mux for this direction */
if (last_searched_direction == CELL_DIRECTION_OUT) circ->n_mux = NULL;
else TO_OR_CIRCUIT(circ)->p_mux = NULL;

/* Now remove it from the map */
HT_REMOVE(chanid_circid_muxinfo_map, cmux->chanid_circid_map, hashent);
Expand Down
5 changes: 0 additions & 5 deletions src/core/or/or_circuit_st.h
Expand Up @@ -33,11 +33,6 @@ struct or_circuit_t {
cell_queue_t p_chan_cells;
/** The channel that is previous in this circuit. */
channel_t *p_chan;
/**
* Circuit mux associated with p_chan to which this circuit is attached;
* NULL if we have no p_chan.
*/
circuitmux_t *p_mux;
/** Linked list of Exit streams associated with this circuit. */
edge_connection_t *n_streams;
/** Linked list of Exit streams associated with this circuit that are
Expand Down
1 change: 0 additions & 1 deletion src/test/test_channel.c
Expand Up @@ -598,7 +598,6 @@ test_channel_outbound_cell(void *arg)
circuit_set_n_circid_chan(TO_CIRCUIT(circ), 42, chan);
tt_int_op(channel_num_circuits(chan), OP_EQ, 1);
/* Test the cmux state. */
tt_ptr_op(TO_CIRCUIT(circ)->n_mux, OP_EQ, chan->cmux);
tt_int_op(circuitmux_is_circuit_attached(chan->cmux, TO_CIRCUIT(circ)),
OP_EQ, 1);

Expand Down
1 change: 0 additions & 1 deletion src/test/test_circuitpadding.c
Expand Up @@ -116,7 +116,6 @@ new_fake_orcirc(channel_t *nchan, channel_t *pchan)

//circ->n_chan = nchan;
circ->n_circ_id = get_unique_circ_id_by_chan(nchan);
circ->n_mux = NULL; /* ?? */
cell_queue_init(&(circ->n_chan_cells));
circ->n_hop = NULL;
circ->streams_blocked_on_n_chan = 0;
Expand Down

0 comments on commit a1a9756

Please sign in to comment.