commit bbb06b73cd46d8e603b9a5b99f2cdd28e31888eb Author: Andrea Shepard andrea@torproject.org Date: Tue Jan 21 20:51:21 2014 -0800
Expose some channel cell queue stuff to the test suite --- src/or/channel.c | 32 +++++--------------------------- src/or/channel.h | 28 ++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 27 deletions(-)
diff --git a/src/or/channel.c b/src/or/channel.c index 9e3e452..76ade4f 100644 --- a/src/or/channel.c +++ b/src/or/channel.c @@ -13,6 +13,9 @@
#define TOR_CHANNEL_INTERNAL_
+/* This one's for stuff only channel.c and the test suite should see */ +#define CHANNEL_PRIVATE_ + #include "or.h" #include "channel.h" #include "channeltls.h" @@ -31,29 +34,6 @@ #include "routerlist.h" #include "scheduler.h"
-/* Cell queue structure */ - -typedef struct cell_queue_entry_s cell_queue_entry_t; -struct cell_queue_entry_s { - TOR_SIMPLEQ_ENTRY(cell_queue_entry_s) next; - enum { - CELL_QUEUE_FIXED, - CELL_QUEUE_VAR, - CELL_QUEUE_PACKED - } type; - union { - struct { - cell_t *cell; - } fixed; - struct { - var_cell_t *var_cell; - } var; - struct { - packed_cell_t *packed_cell; - } packed; - } u; -}; - /* Global lists of channels */
/* All channel_t instances */ @@ -175,7 +155,6 @@ static cell_queue_entry_t * cell_queue_entry_new_fixed(cell_t *cell); static cell_queue_entry_t * cell_queue_entry_new_var(var_cell_t *var_cell); -static int chan_cell_queue_len(const chan_cell_queue_t *queue); static int is_destroy_cell(channel_t *chan, const cell_queue_entry_t *q, circid_t *circid_out);
@@ -1751,9 +1730,8 @@ channel_get_cell_queue_entry_size(channel_t *chan, cell_queue_entry_t *q) rv = get_cell_network_size(chan->wide_circ_ids); break; case CELL_QUEUE_VAR: - tor_assert(q->u.var.var_cell); rv = get_var_cell_header_size(chan->wide_circ_ids) + - q->u.var.var_cell->payload_len; + (q->u.var.var_cell ? q->u.var.var_cell->payload_len : 0); break; case CELL_QUEUE_PACKED: rv = get_cell_network_size(chan->wide_circ_ids); @@ -3455,7 +3433,7 @@ channel_listener_describe_transport(channel_listener_t *chan_l) /** * Return the number of entries in <b>queue</b> */ -static int +STATIC int chan_cell_queue_len(const chan_cell_queue_t *queue) { int r = 0; diff --git a/src/or/channel.h b/src/or/channel.h index 023c39d..ba6d66b 100644 --- a/src/or/channel.h +++ b/src/or/channel.h @@ -354,6 +354,34 @@ void channel_set_cmux_policy_everywhere(circuitmux_policy_t *pol);
#ifdef TOR_CHANNEL_INTERNAL_
+#ifdef CHANNEL_PRIVATE_ +/* Cell queue structure (here rather than channel.c for test suite use) */ + +typedef struct cell_queue_entry_s cell_queue_entry_t; +struct cell_queue_entry_s { + TOR_SIMPLEQ_ENTRY(cell_queue_entry_s) next; + enum { + CELL_QUEUE_FIXED, + CELL_QUEUE_VAR, + CELL_QUEUE_PACKED + } type; + union { + struct { + cell_t *cell; + } fixed; + struct { + var_cell_t *var_cell; + } var; + struct { + packed_cell_t *packed_cell; + } packed; + } u; +}; + +/* Cell queue functions for benefit of test suite */ +STATIC int chan_cell_queue_len(const chan_cell_queue_t *queue); +#endif + /* Channel operations for subclasses and internal use only */
/* Initialize a newly allocated channel - do this first in subclass
tor-commits@lists.torproject.org