Ticket #7743: 11734484.txt

File 11734484.txt, 986 bytes (added by nickm, 7 years ago)
Line 
1--- connection_edge.bug7743_023_alt2.c
2+++ connection_edge.c
3@@ -153,7 +153,9 @@
4     return;
5 
6   avail = connection_get_inbuf_len(conn) + n_on_socket;
7+  if (avail > RELAY_PAYLOAD_SIZE)
8+    avail = (avail / RELAY_PAYLOAD_SIZE) * RELAY_PAYLOAD_SIZE;
9+    /* XYZ: (avail - (avail % RELAY_PAYLOAD_SIZE)) better? */
10   edge_conn->avail_to_package = avail;
11 }
12 
13 /** Handle new bytes on conn->inbuf based on state:
14
15--- connection.bug7743_023_alt2.c
16+++ connection.c
17@@ -2773,8 +2773,13 @@
18     at_most = connection_bucket_read_limit(conn, approx_time());
19   }
20 
21-  if (CONN_IS_EDGE(conn))
22+  if (CONN_IS_EDGE(conn)) {
23+    ssize_t inbuf_len = connection_get_inbuf_len(conn);
24+    if (at_most > RELAY_PAYLOAD_SIZE) {
25+      at_most = at_most + inbuf_len;
26+      at_most = (at_most / RELAY_PAYLOAD_SIZE) * RELAY_PAYLOAD_SIZE;
27+      at_most = at_most - inbuf_len;
28+    }
29     connection_edge_set_min_to_package(TO_EDGE_CONN(conn));
30+  }
31 
32   slack_in_buf = buf_slack(conn->inbuf);
33  again: