URL:
<
https://savannah.nongnu.org/bugs/?59182>
Summary: Fresh socket does not raise ENOTCONN
Project: lwIP - A Lightweight TCP/IP stack
Submitted by: gvanem
Submitted on: Sat 26 Sep 2020 07:50:22 AM UTC
Category: sockets/netconn
Severity: 3 - Normal
Item Group: Faulty Behaviour
Status: None
Privacy: Public
Assigned to: None
Open/Closed: Open
Discussion Lock: Any
Planned Release: None
lwIP version: git head
_______________________________________________________
Details:
I have patched MicroPython [1] with LwIP support on Windows.
And running some tcp/ip related test shows a funny behaviour in LwIP.
E.g. from:
https://github.com/micropython/micropython/blob/master/tests/extmod/usocket_tcp_basic.py # recv() on a fresh socket should raise ENOTCONN
s = socket.socket()
try:
s.recv(1)
except OSError as er:
print("ENOTCONN:", er.args[0] == errno.ENOTCONN)
The trace in LwIP shows:
src/api/sockets.c(1754): lwip_socket(PF_INET, SOCK_STREAM, 0) = 0
src/api/sockets.c(1243): lwip_recvfrom(0, 0E88A030, 1, 0x0, ..)
src/api/sockets.c(976): lwip_recv_tcp: top while sock->lastdata=00000000
Now the MicroPython test hangs forever. Nothing happens
with this socket 0. It's unconnected, so how could this socket
ever receive a single byte?
Using the same .py-test in the real CPython 3.6, it immediately
returns the expected:
py -3 extmod\usocket_tcp_basic.py
ENOTCONN: True
Also not that the sock-fd == 0. Rebuilding LwIP with:
-DLWIP_SOCKET_OFFSET=100
to force a sock-fd to start at 100, does not make any change
to the hang.
[1]
https://github.com/micropython/micropython _______________________________________________________
Reply to this item at:
<
https://savannah.nongnu.org/bugs/?59182>
_______________________________________________
Message sent via Savannah
https://savannah.nongnu.org/_______________________________________________
lwip-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-devel