aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrea Shepard <andrea@torproject.org>2012-10-10 00:19:57 -0700
committerAndrea Shepard <andrea@torproject.org>2012-10-10 00:44:47 -0700
commit217352c3624aa62384af57a2e7046e577671b915 (patch)
tree3238451d30e421d5b144cdf5d1dc1871bb61b00f
parentbec776480d673dc85afd2a3db052f3d8eb81a5c4 (diff)
downloadtor-217352c3624aa62384af57a2e7046e577671b915.tar
tor-217352c3624aa62384af57a2e7046e577671b915.tar.gz
Make channel_flush_some_cells() compile cleanly on machines with ssize_t larger than int per sjumrdoch comment
-rw-r--r--src/or/channel.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/or/channel.c b/src/or/channel.c
index 880fa63ca..1ca5e1a33 100644
--- a/src/or/channel.c
+++ b/src/or/channel.c
@@ -2018,7 +2018,7 @@ channel_flush_some_cells(channel_t *chan, ssize_t num_cells)
{
unsigned int unlimited = 0;
ssize_t flushed = 0;
- int num_cells_from_circs;
+ int num_cells_from_circs, clamped_num_cells;
tor_assert(chan);
@@ -2033,12 +2033,20 @@ channel_flush_some_cells(channel_t *chan, ssize_t num_cells)
if (!unlimited && num_cells <= flushed) goto done;
if (circuitmux_num_cells(chan->cmux) > 0) {
+ /* Calculate number of cells, including clamp */
+ if (unlimited) {
+ clamped_num_cells = MAX_CELLS_TO_GET_FROM_CIRCUITS_FOR_UNLIMITED;
+ } else {
+ if (num_cells - flushed >
+ MAX_CELLS_TO_GET_FROM_CIRCUITS_FOR_UNLIMITED) {
+ clamped_num_cells = MAX_CELLS_TO_GET_FROM_CIRCUITS_FOR_UNLIMITED;
+ } else {
+ clamped_num_cells = (int)(num_cells - flushed);
+ }
+ }
/* Try to get more cells from any active circuits */
num_cells_from_circs = channel_flush_from_first_active_circuit(
- chan,
- (unlimited ?
- MAX_CELLS_TO_GET_FROM_CIRCUITS_FOR_UNLIMITED :
- (num_cells - flushed)));
+ chan, clamped_num_cells);
/* If it claims we got some, process the queue again */
if (num_cells_from_circs > 0) {