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

Submitter:  Joel Palsson <jpa>
Submitted:  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

Tue 22 Feb 2022 07:54:37 AM UTC, comment #5: 

Doesn't seem fixed in master, let's check this again...

Simon Goldschmidt <goldsimon>
Group administrator
Sat 19 Feb 2022 08:55:51 PM UTC, comment #4: 

This is already fixed in master branch (see attached patch)

Simon Goldschmidt <goldsimon>
Group administrator
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>
Group 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>
Group 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>


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

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)

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.


    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-02-22 goldsimon StatusFixed None
        Open/ClosedClosed Open
    2022-02-19 goldsimon StatusNone Fixed
        Open/ClosedOpen Closed
    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.13-ee12.
    Corresponding source code