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
This commit is contained in:
Emery Hemingway 2019-02-19 12:04:53 +01:00 committed by Christian Helmuth
parent 8ca887a25c
commit 2fa7964a39

View File

@ -888,8 +888,6 @@ class Lwip::Udp_socket_dir final :
pbuf *buf = pbuf_alloc(PBUF_RAW, remain, PBUF_RAM); pbuf *buf = pbuf_alloc(PBUF_RAW, remain, PBUF_RAM);
pbuf_take(buf, src, buf->tot_len); 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); err_t err = udp_sendto(_pcb, buf, &_to_addr, _to_port);
pbuf_free(buf); pbuf_free(buf);
if (err != ERR_OK) if (err != ERR_OK)
@ -1207,9 +1205,9 @@ class Lwip::Tcp_socket_dir final :
u16_t new_off; u16_t new_off;
pbuf *new_head = pbuf_skip(_recv_pbuf, _recv_off, &new_off); pbuf *new_head = pbuf_skip(_recv_pbuf, _recv_off, &new_off);
if (new_head != NULL && new_head != _recv_pbuf) { 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_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); pbuf_free(_recv_pbuf);
} }