lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-users] Raw TCP, intermittent long delays in accept after after


From: Geoff Simmons
Subject: Re: [lwip-users] Raw TCP, intermittent long delays in accept after after close
Date: Thu, 20 Oct 2022 20:22:08 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.0

On 10/12/22 21:13, goldsimon@gmx.de wrote:
Sorry, nothing comes to mind except for maybe you don't close your TCP
pcbs correctly. Normally, pcbs in time-wait should just be reused. If
you experience you need some kind of delay, maybe your pcbs are stuck in
a state != time-wait?

Nevertheless thanks for the response, it helps to know at least that the hypothesis about closing the pcbs isn't completely unreasonable.

I do indeed suspect that pcbs (at least some of them) are not in TIME_WAIT. What are the options for debugging to find that out? One of the debug flags (might have been TCPIP_DEBUG, but I'm not sure if I remember correctly) looked as if it might show that. But the output was so verbose that I couldn't follow.

Let me try to give a brief rundown of what the app does to close connections (trying to keep it short this time, honestly). In case a reader of the list might notice an error or omission.

This is an HTTP server, so connections are only closed if the tcp_recv callback is called with the pbuf==NULL (client initiated the close); or if there was an error, or an idle timeout for an open connection elapsed (in the latter two cases, the server initiates the close).

The app keeps track of ACK'd bytes that were sent in the tcp_sent callback. If a close is desired, but not all bytes have been ACK'd, the close is deferred. If a close is pending, and the tcp_sent or tcp_poll callback determines that all bytes were ACK'd, then the close proceeds.

When the server is ready to close, it calls tcp_close(); if tcp_close() does not return ERR_OK, it calls tcp_abort(). If it was tcp_abort(), then tcp_arg and the tcp_poll and tcp_err callbacks are retained. tcp_poll or tcp_err then initiate finalizing the pcb. Otherwise (tcp_close() succeeded), the pcb is finalized right away.

The pcb is finalized by setting tcp_arg and all of the callbacks to NULL.

That's an involved procedure, so it wouldn't surprise me if something isn't quite right.


Thanks,
Geoff




reply via email to

[Prev in Thread] Current Thread [Next in Thread]