[bug #59182] Fresh socket does not raise ENOTCONN

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

[bug #59182] Fresh socket does not raise ENOTCONN


                 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



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:

  # recv() on a fresh socket should raise ENOTCONN
  s = socket.socket()
  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

Also not that the sock-fd == 0. Rebuilding LwIP with:

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:


  Message sent via Savannah

lwip-devel mailing list
[hidden email]