buglwIP - A Lightweight TCP/IP stack - Bugs: bug #38468, tcp_sent() not called on half-open...

 
 

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

bug #38468: tcp_sent() not called on half-open connection for data ACKed with the same ack as FIN

Submitter:  Valery Ushakov <uwe>
Submitted:  Tue 05 Mar 2013 02:12:05 AM UTC
   
 
Category:  TCP Severity:  3 - Normal
Item Group:  Faulty Behaviour Status:  Fixed
Privacy:  Public Assigned to:  goldsimon
Open/Closed:  Closed Planned Release:  None
lwIP version:  git head

Sat 21 Mar 2015 08:00:07 PM UTC, comment #2: 

Fixed, thanks for reporting.

In applications like these, you have to take special care about not referencing the pcb after tcp_close() returns success. However, this bugfix should ensure you either get all 'sent' events or an 'err' callback, even though you don't reference the pcb any more.

Simon Goldschmidt <goldsimon>
Group administrator
Sat 21 Mar 2015 07:40:53 PM UTC, comment #1: 

I do think this is a bug: we should issue TCP_EVENT_SENT() in the TF_CLOSED case, too.

Simon Goldschmidt <goldsimon>
Group administrator
Tue 05 Mar 2013 02:12:05 AM UTC, original submission:  

I'm not sure if it's a bug or if I'm doing something wrong, so feel free
to close as invalid.

I have a pcb that ignores input and sends a blob of data as fast as it
can.  The client that connects to that pcb immediately half-closes after
connect.  When pcb is done sending it shuts down its end of the
connection too, it doesn't wait for all data to be acked before shutting
down, but it keeps tcp_sent() and tcp_err() callbacks in place and
tracks acks.

When peer receives all data and the FIN from the pcb it will send the
final datagram that ACKs both the last bit of data and the FIN.

After calling tcp_process(), tcp_input() sees TF_CLOSED in recv_flags
and goes into that else-if branch that does TCP_EVENT_ERR(ERR_CLSD) and
doesn't do TCP_EVENT_SENT(pcb->acked) for the last chunk of acked data.

As a workaround I can do in my tcp_err() callback something along the
lisnes of:

    if (err == ERR_CLSD) {
       /* we know from RTFS that pcb is still alive at this point */
       struct tcp_pcb *pcb = /* get pcb from user data in arg */;

       if (pcb->acked > 0) {
           my_sent_callback(arg, pcb, pcb->acked);
       }
    }

which mimics missing TCP_EVENT_SENT (a few lines later in tcp_input() in
the else branch).

Valery Ushakov <uwe>

 

(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 goldsimon (Posted a comment)
  • -email is unavailable- added by uwe (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 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2015-03-21 goldsimon StatusIn Progress Fixed
    2015-03-21 goldsimon Open/ClosedOpen Closed
    2015-03-21 goldsimon StatusNone In Progress
        Assigned toNone goldsimon

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code