]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
refactor logic to decide how much to package from inbuf
authorRoger Dingledine <arma@torproject.org>
Thu, 19 Jul 2018 01:00:27 +0000 (21:00 -0400)
committerNick Mathewson <nickm@torproject.org>
Thu, 23 May 2019 12:28:46 +0000 (08:28 -0400)
no actual changes in behavior

src/core/or/relay.c

index 5197ee61380d6efedf949a231ad200a447e140d1..05fee57a1aa3b31d949827125d19f40e36e4781d 100644 (file)
@@ -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;