diff options
author | Masaq- <tilt@techie.com> | 2019-02-28 02:18:15 +0000 |
---|---|---|
committer | Masaq- <tilt@techie.com> | 2019-02-28 02:18:15 +0000 |
commit | ca931dfbce1f53aa510e4974fbcc584ee4d8744e (patch) | |
tree | 4de213c4cfabc092288b912a58180a133a9781f4 | |
parent | f5f395ed7211e39825745da63a2a713e2679c17a (diff) |
realloc rings for larger window size
-rw-r--r-- | src/pkt.c | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -430,10 +430,14 @@ void handle_extended_options(void *vcur) { proxy_desc_t *cur = (proxy_desc_t *)vcur; if (cur->extended_options[0] > 0) { - remove_proxy_desc_rings(cur); + if (cur->extended_options[0] > cur->window_size) { + size_t extend = cur->extended_options[0] - cur->window_size; + cur->send_ring = realloc(cur->send_ring, cur->extended_options[0] * sizeof(icmp_desc_t)); + cur->recv_ring = realloc(cur->recv_ring, cur->extended_options[0] * sizeof(forward_desc_t *)); + memset(cur->send_ring + cur->window_size, 0, extend * sizeof(icmp_desc_t)); + memset(cur->recv_ring + cur->window_size, 0, extend * sizeof(forward_desc_t *)); + } cur->window_size = cur->extended_options[0]; - cur->send_ring = calloc(cur->window_size, sizeof(icmp_desc_t)); - cur->recv_ring = calloc(cur->window_size, sizeof(forward_desc_t *)); pt_log(kLog_verbose, "Received extended option for window size %d \n", cur->window_size); } if (cur->extended_options[1] > 0) { |