aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2018-07-18 21:00:27 -0400
committerNick Mathewson <nickm@torproject.org>2019-05-23 08:28:46 -0400
commite4d1187584038593a75140d9a8e47024c9eba04c (patch)
tree3d8d6fb7dc766eac060280ce6ed4bafac752373f /src
parentebe39dcb9225ffe43c6b6d2fe49d4b99d155ff33 (diff)
downloadtor-e4d1187584038593a75140d9a8e47024c9eba04c.tar.gz
tor-e4d1187584038593a75140d9a8e47024c9eba04c.zip
refactor logic to decide how much to package from inbuf
no actual changes in behavior
Diffstat (limited to 'src')
-rw-r--r--src/core/or/relay.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/core/or/relay.c b/src/core/or/relay.c
index 5197ee6138..05fee57a1a 100644
--- a/src/core/or/relay.c
+++ b/src/core/or/relay.c
@@ -2102,14 +2102,15 @@ connection_edge_package_raw_inbuf(edge_connection_t *conn, int package_partial,
if (!bytes_to_process)
return 0;
- if (!package_partial && bytes_to_process < RELAY_PAYLOAD_SIZE)
- return 0;
+ length = RELAY_PAYLOAD_SIZE;
- if (bytes_to_process > RELAY_PAYLOAD_SIZE) {
- length = RELAY_PAYLOAD_SIZE;
- } else {
- length = bytes_to_process;
+ if (bytes_to_process < length) { /* not a full payload available */
+ if (package_partial)
+ length = bytes_to_process; /* just take whatever's available now */
+ else
+ return 0; /* nothing to do until we have a full payload */
}
+
stats_n_data_bytes_packaged += length;
stats_n_data_cells_packaged += 1;