From 2fa7964a396fca8e6ae8c85b7ec9f63cdc50eaa5 Mon Sep 17 00:00:00 2001 From: Emery Hemingway Date: Tue, 19 Feb 2019 12:04:53 +0100 Subject: [PATCH] VFS lwIP: fix TCP pbuf unchaining The lwIP VFS plugin uses lwIP pbuf chains to queue recieved TCP data and must rechain them when the application dequeues data. Remove an "pbuf_realloc" call which is not needed for updating pbuf metadata when dequeuing the head of the chain. Fix #3169 --- repos/libports/src/lib/vfs/lwip/vfs.cc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/repos/libports/src/lib/vfs/lwip/vfs.cc b/repos/libports/src/lib/vfs/lwip/vfs.cc index f16d8be331..bf74733807 100644 --- a/repos/libports/src/lib/vfs/lwip/vfs.cc +++ b/repos/libports/src/lib/vfs/lwip/vfs.cc @@ -888,8 +888,6 @@ class Lwip::Udp_socket_dir final : pbuf *buf = pbuf_alloc(PBUF_RAW, remain, PBUF_RAM); pbuf_take(buf, src, buf->tot_len); - char shit[ENDPOINT_STRLEN_MAX]; - ipaddr_aton(shit, &_to_addr); err_t err = udp_sendto(_pcb, buf, &_to_addr, _to_port); pbuf_free(buf); if (err != ERR_OK) @@ -1207,9 +1205,9 @@ class Lwip::Tcp_socket_dir final : u16_t new_off; pbuf *new_head = pbuf_skip(_recv_pbuf, _recv_off, &new_off); if (new_head != NULL && new_head != _recv_pbuf) { - /* move down the buffer and deref the head */ + /* increment the references on the new head */ pbuf_ref(new_head); - pbuf_realloc(new_head, _recv_pbuf->tot_len+_recv_off); + /* free the buffers chained to the old head */ pbuf_free(_recv_pbuf); }