[riot-notifications] [RIOT-OS/RIOT] lwip_sock: Fix computation of last_offset on partial reads. (#16278)
notifications at github.com
Sun Apr 4 12:50:21 CEST 2021
### Contribution description
lwip receives network buffers that are made available to lwip_sock_tcp
calling `netconn_recv_tcp_pbuf`. The size of these buffers depends on
the size of the network packets. An application calling `sock_tcp_read`
can pass any arbitrary buffer size to read (copy) from these internal
network buffers, which may be smaller. lwip_sock_tcp keeps around the
last network buffer (`struct pbuf last_buf`) and the offset into this
buffer already consumed by the application (`last_offset`).
However, when multiple application reads from the same `pbuf` buffer
occur, the `last_offset` must be updated incrementing it. The code had
a bug that would work only when `last_offset` was either 0 (no previous
partial read) or when the current read was consuming all the remaining
data (when `buf_len == copylen`).
This patch fixes the issue an allows multiple reads from the same
### Testing procedure
Tested using `tests/lwip` with TCP network payloads of 536 bytes and reading 256 bytes at a time.
### Issues/PRs references
You can view, comment on, or merge this pull request online at:
-- Commit Summary --
* lwip_sock: Fix computation of last_offset on partial reads.
-- File Changes --
M pkg/lwip/contrib/sock/tcp/lwip_sock_tcp.c (2)
-- Patch Links --
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the notifications