buglwIP - A Lightweight TCP/IP stack - Bugs: bug #56147, lwip_select() does not always...


You are not allowed to post comments on this tracker with your current authentication level.

bug #56147: lwip_select() does not always wakup on received data

Submitted by:  Joel Palsson <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 Planned Release:  None
lwIP version:  Other

Thu 16 May 2019 06:07:22 PM UTC, comment #3: 

Ok, so reading the patch you attached, this is something fixed in master but not fixed for 2.1.2? If so, please do cherry-picking properly: leave the commit message intact and add a correct commit hash from master that you picked from.

Ideally, point us to the bug # of the fix here, too.

Simon Goldschmidt <goldsimon>
Project Administrator
Tue 14 May 2019 07:38:32 PM UTC, comment #2: 

Time for lwIP is short lately for all "active" members of the team, so if you could provide a patch fixing this (I haven't reproduced this, yet)...

Simon Goldschmidt <goldsimon>
Project Administrator
Thu 18 Apr 2019 05:58:23 AM UTC, comment #1: 

LWIP version 2.1.2
The line for the fix is incorrect in the original submission. It should be line 1010.

Joel Palsson <jpa>
Wed 17 Apr 2019 02:42:23 PM UTC, original submission:  

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:
          ->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));


} while ((recv_left > 0) && !(flags & MSG_PEEK) && (sock->rcvevent > 0) );

Joel Palsson <jpa>


Attached Files
file #46910:  0001-Fixed-problem-in-LWIP-where-select-did-not-always-wa.patch added by jpa (1KiB - application/octet-stream - Added Git patch)


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by goldsimon (Posted a comment)
  • -email is unavailable- added by jpa (Submitted the item)
  • -email is unavailable- added by jpa (lwip_select() won't always wake)

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.




    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-05-15 jpa Attached File- => Added 0001-Fixed-problem-in-LWIP-where-select-did-not-always-wa.patch, #46910
    2019-04-17 jpa Carbon-Copy- => Added jpa

    Back to the top

    Powered by Savane 3.5