Mon 12 Oct 2015 06:43:48 AM UTC, original submission:
In my application I use several interfaces (up to 32). The behaviour described below can be reproduced easier with more than 1 interface but occurs also with only 1 interface.
After startup, I create 2 UDP sockets for each interface but do not bind them because I do not know the IP address yet.
For each socket I have a separate receive thread calling "lwip_recvfrom". The function returns an error because the socket is not bound and I ignore the error.
At some point the sockets are bound to an IP address by calling
- lwip_close()
- lwip_socket()
- lwip_bind()
I have been using this kind of implementation with native sockets from Windows, Linux and VxWorks without any problems.
Most of the time the behaviour after that is correct and packets are received properly in the receive thread(s).
But sporadically received packets are not delivered to "lwip_recfrom".
The packet is transferred through functions "udp_input" to "recv_udp" but the mailbox does not deliver the packet to "netconn_recv_data" and therefore to "lwip_recfrom".
The behaviour is the same under Linux and Windows so I think the mailbox handling itself is not the source of the problem.
The error seems to occur in case the function "sys_mbox_trypost" is called before the function "lwip_recvfrom" (netconn_recv_data) is ready to receive the data.
I have attached to files with (also self made) debug outputs in case the connection is ok and not ok.
In case the connection is ok, "lwip_recvfrom" is called before "udp_input" after the rebind.
In case the connection is not ok, "udp_input" is called before "lwip_recvfrom".
|