buglwIP - A Lightweight TCP/IP stack - Bugs: bug #36494, tcp_recved is not called when a...

 
 

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

bug #36494: tcp_recved is not called when a remote TCP connection is closed

Submitter:  Bill Auerbach <billauerbach>
Submitted:  Fri 18 May 2012 08:58:50 PM UTC
   
 
Category:  TCP Severity:  3 - Normal
Item Group:  Faulty Behaviour Status:  Invalid
Privacy:  Public Assigned to:  None
Open/Closed:  Closed Planned Release:  None
lwIP version:  CVS Head

Fri 01 Jun 2012 06:24:55 PM UTC, comment #3: 

Yes, more documentation would undoubtedly help - it needed you could trace through the git history to work out the reason for this change, but as you seem to have what you need I'll close this as requested

Kieran Mansley <kieranm>
Group Member
Mon 21 May 2012 02:42:49 PM UTC, comment #2: 

The problem with not getting a tcp_err callback is traced to the test of the return code from TCP_EVENT_ACCEPT.  I was returning ERR_ABRT to indicate to abort the connection.

In lwIP 1.3.x if err is not ERR_OK the outcome was to call tcp_abort.

In lwIP 1.4.x if err is not ERR_OK and not ERR_ABRT tcp_abort is called.  I see this change:

/* Already aborted? */
if (err != ERR_ABRT) {

was added - I don't recall seeing the change note or reason but it effected my code.

Now I return a different ERR code and I'm back to how it used to work for me.  This is a case where the simplest of changes can break a program.  I don't see any documentation on what the expected return codes from tcp_accepted should be.  I'm not saying that it doesn't exist - a quick read of the Wiki doesn't detail it.

This "bug" can be closed.

Bill Auerbach <billauerbach>
Fri 18 May 2012 10:22:37 PM UTC, comment #1: 

Turns out this can be (is on WinXP) caused by setting SOCKOPT SO_LINGER.  I didn't know this causes a Reset.

However, my code is handling tcp_err and tcp_recevd callbacks to clean up my wrapper around a tcp_pcb and the tcp_err callback is not called every time when the remote resets.  As my code hasn't changed on the PC or target I believe this behavior is fairly new.  I never got out of sync with my wrapper in a state with the TCP connection that was open while lwIP knew it was closed.  This is why I got into this debugging in the first place - I had rare occurrences of being out of sync - I thought the TCP connection was open while lwIP had the reset and knew it was closed because of a missed tcp_err callback.

I believe some testing should be done by others: Resetting the remote connection and seeing that the tcp_err callback is made every time.

Bill Auerbach <billauerbach>
Fri 18 May 2012 08:58:50 PM UTC, original submission:  

Using NO_SYS=1 and the RAW callback API, I just discovered that when a remote TCP connection is closed (a normal close) tcp_recved is not called with struct pbuf *p == NULL but instead tcp_err is called.  That conflicts with how I think it used to be and definitely with how the Wiki describes closing a socket should be handled.

Bill Auerbach <billauerbach>

 

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

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by kieranm (Posted a comment)
  • -email is unavailable- added by billauerbach (Submitted the item)
  •  

    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 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2012-06-01 kieranm StatusNone Invalid
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code