[riot-notifications] [RIOT-OS/RIOT] lwip_sock: Fix computation of last_offset on partial reads. (#16278)

iosabi notifications at github.com
Tue Apr 6 19:58:14 CEST 2021


> How can I do that?

Sorry I didn't make this more specific. Here's how I just reproduced the issue:
1. Compile `test/lwip` for esp12x (I'm trying out with the adafruit huzzah breakout board): `CFLAGS='-DESP_WIFI_SSID=\"mysecurewifi\" -DESP_WIFI_PASS=\"hunter2\"' make BOARD=esp8266-esp-12x -C tests/lwip LWIP_IPV4=1 flash`
2. Connect with your favorite terminal, I used `picocom -b 115200 /dev/ttyUSB0 --lower-rts --lower-dtr --imap lfcrlf`
3. `ifconfig` on the riot shell to get the IP.
4. `tcp server start 1234` to start a tcp server on port 1234 (using async socks, which are quite experimental).
5. On another terminal run: `(sleep 1; cat tests/lwip/common.c) | nc -n -v 1.2.3.4 1234` where `1.2.3.4` is the IP from step 3.

tests/lwip/tcp.c calls `sock_tcp_read` with a 256 bytes buffer (`SOCK_INBUF_SIZE`) but what I see on my network with wireshark is that the TCP packet was larger than that (1072 TCP payload size), so this forces multiple partial reads.

With this fix you should see the file being dumped in hex. The `sleep 1` is because of a bug in sock_async that I need to open an issue about, but ignore it for now.

Without this fix you should see the first 256 bytes dumped, then the second 256 bytes dumped and then an infinite loop of the second 256 bytes dumped since last_offset is kept at 256 after the first iteration.

I ran into other issues while testing this (including a few Exceptions) but this PR is just for this one tiny fix.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/16278#issuecomment-814322181
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20210406/6b2324cb/attachment-0001.htm>


More information about the notifications mailing list