buglwIP - A Lightweight TCP/IP stack - Bugs: bug #26672, close connection when receive...

 
 

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

bug #26672: close connection when receive window = 0

Submitter:  Oleg Tyshev <olegreen>
Submitted:  Mon 25 May 2009 02:25:46 PM UTC
   
 
Category:  TCP Severity:  3 - Normal
Item Group:  Change Request Status:  Fixed
Privacy:  Public Assigned to:  goldsimon
Open/Closed:  Closed Planned Release:  None
lwIP version:  CVS Head

Fri 08 Jan 2010 03:10:17 PM UTC, comment #4: 

Checked in -> fixed.

Simon Goldschmidt <goldsimon>
Group administrator
Mon 26 Oct 2009 09:30:41 AM UTC, comment #3: 

Let's hold this for 1.4.0

Kieran Mansley <kieranm>
Group Member
Sun 25 Oct 2009 06:56:28 PM UTC, comment #2: 

Since I tested it and it's mainly code moved to another location, I'd regard this as low risk (meaning 1.3.2), any thoughts on that?

Currently, recvmbox/acceptmbox are drained in the application thread, in netconn_delete->neconn_free (after do_delconn).

The attached patch moves the draining into an extra function (netconn_drain), which is called from netconn_delete before calling do_delconn. The amount of drained data is passed to do_delconn (tcpip_thread), which can call tcp_recved/tcp_accepted accordingly.

The only downside of this approach is that, while draining, recvmbox & acceptmbox are set to NULL from the application thread, meaning there is a tiny gap where recv_tcp/accept_function may see them as NULL and must handle that correctly (covered by the patch).

I have tested it and together with a bug-fix in the TCP_EVENT_RECV macro (has to call tcp_recved if pcb->recv is NULL), it works decently (remote side can transfer data until it closes the connection, but that's another bug).

(file #18940)

Simon Goldschmidt <goldsimon>
Group administrator
Sun 25 Oct 2009 12:07:45 PM UTC, comment #1: 

This is a bit tricky: I'd suggest draining the recvmbox/acceptmbox from netconn_delete before calling do_delconn. This would mean that after a call to lwip_close/netconn_delete, no more data can be received, but that's what we want.

I'd add a new function netconn_drain, that drains and frees conn->recvmbox and conn->acceptmbox while calling tcp_recved() and tcp_accepted() so that the counters are correct afterwards.

Simon Goldschmidt <goldsimon>
Group administrator
Mon 25 May 2009 02:25:46 PM UTC, original submission:  

lwip_close should close both directions send and receive.

lwip_close deletes data in receive buffer, but receive window won't be updated.

If it was situation with zero receive window,
other side can't send FIN, because receive window = 0.

In do_close_internal() will be only tcp_close() called.
It is necessary here set initial receive window.


Oleg Tyshev <olegreen>

 

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

Attached Files
file #18940:  lwip_26672_1.patch added by goldsimon (8KiB - text/x-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 kieranm (Updated the item)
  • -email is unavailable- added by olegreen (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 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2010-01-08 goldsimon StatusIn Progress Fixed
        Open/ClosedOpen Closed
    2009-10-25 goldsimon StatusNone In Progress
        Assigned toNone goldsimon
    2009-10-25 goldsimon Attached File- Added lwip_26672_1.patch, #18940
    2009-08-20 kieranm Planned Release 1.4.0

    Back to the top

    Powered by Savane 3.13-bb6a.
    Corresponding source code