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

Submitted by:  Oleg Tyshev <olegreen>
Submitted on:  Mon 25 May 2009 02:25:46 PM UTC  
 
Category: TCPSeverity: 3 - Normal
Item Group: Change RequestStatus: Fixed
Privacy: PublicAssigned to: Simon Goldschmidt <goldsimon>
Open/Closed: ClosedPlanned Release: None
lwIP version: CVS Head

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

Checked in -> fixed.

Simon Goldschmidt <goldsimon>
Project AdministratorIn charge of this item.
Mon 26 Oct 2009 09:30:41 AM UTC, comment #3:

Let's hold this for 1.4.0

Kieran Mansley <kieranm>
Project Administrator
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>
Project AdministratorIn charge of this item.
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>
Project AdministratorIn charge of this item.
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>

 

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
  • -unavailable- added by goldsimon (Posted a comment)
  • -unavailable- added by kieranm (Updated the item)
  • -unavailable- added by olegreen (Submitted the item)
  •  

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

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 6 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Fri 08 Jan 2010 03:10:17 PM UTCgoldsimonStatusIn Progress=>Fixed
      Open/ClosedOpen=>Closed
    Sun 25 Oct 2009 06:56:44 PM UTCgoldsimonStatusNone=>In Progress
      Assigned toNone=>goldsimon
    Sun 25 Oct 2009 06:56:27 PM UTCgoldsimonAttached File-=>Added lwip_26672_1.patch, #18940
    Thu 20 Aug 2009 02:14:17 PM UTCkieranmPlanned Release=>1.4.0

    Back to the top


    Powered by Savane 3.1-cleanup1