[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lwip-devel] [bug #56147] lwip_select() does not always wakup on receive
From: |
Joel Palsson |
Subject: |
[lwip-devel] [bug #56147] lwip_select() does not always wakup on received data |
Date: |
Wed, 17 Apr 2019 10:42:25 -0400 (EDT) |
User-agent: |
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36 |
URL:
<https://savannah.nongnu.org/bugs/?56147>
Summary: lwip_select() does not always wakup on received data
Project: lwIP - A Lightweight TCP/IP stack
Submitted by: jpa
Submitted on: Wed 17 Apr 2019 02:42:23 PM 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: Other
_______________________________________________________
Details:
This pseudocode would result in lwip_select() waking up for data received once
(if less than 1000 bytes), but not second time data is received:
while( 1 )
{
lwip_select( maxfdp1, &readset, NULL, NULL, NULL);
lwip_read( s, pData, 1000 );
}
The reason is that when first data is read with lwip_read(), the loop in
lwip_recv_tcp() is not exited resulting in calling
netconn_recv_tcp_pbuf_flags() twice which will call:
->netconn_recv_data_tcp()
->netconn_recv_data()
->API_EVENT(conn, NETCONN_EVT_RCVMINUS, len);
That results in decrementing the sock->rcvevent twice which, if only one
receive event has occured, will then be -1. So next receive event will restore
it to 0, but select() won't wake since it should be >0.
A fix is to change the exit condition for the loop in lwip_recv_tcp() in
socket.c at line 1025 from
} while ((recv_left > 0) && !(flags & MSG_PEEK));
to
} while ((recv_left > 0) && !(flags & MSG_PEEK) && (sock->rcvevent > 0) );
_______________________________________________________
Reply to this item at:
<https://savannah.nongnu.org/bugs/?56147>
_______________________________________________
Message sent via Savannah
https://savannah.nongnu.org/
- [lwip-devel] [bug #56147] lwip_select() does not always wakup on received data,
Joel Palsson <=