You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Defer closing the connection to the async thread when processing a fin event. This allows client connections to process all received data before the connection is terminated.
This can be slightly more expensive for servers who are handling unexpected client termination as they may still process now-pointless ack events, but should have no effect on the normal case (as the server closes when it's done sending). I did a quick perftest with AsyncWebServer and saw no significant performance difference.
Only concern is to not try to access the now probably gone pcb
The FIN event doesn't invalidate the pcb; a half-closed connection is a legal TCP state. LwIP handles this correctly. The pcb won't be invalidated until we call tcp_close() or tcp_abort() on it. It's only the tcp_err() callback that forces us to deal with a pcb that's going to be invalidated by the library without us explicitly calling in to release it.
Historically, though, half-closed connections have been a somewhat curious corner of the TCP standard. This is because the traditional UNIX sockets API can't represent it: FIN is sent when close() is called on a socket, after which it can no longer read() any data sent by the other side (because the file handle is invalidated). So it's not entirely unreasonable for the remote partner to assume that FIN means "nothing I send now will be visible to the client", therefore I might as well close up this connection. But that is a sockets-ism; it's perfectly legal in the TCP standard for a connection to continue to process and ACK incoming data after sending a FIN to its partner to let it know that its side is finished sending data.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Defer closing the connection to the async thread when processing a fin event. This allows client connections to process all received data before the connection is terminated.
This can be slightly more expensive for servers who are handling unexpected client termination as they may still process now-pointless ack events, but should have no effect on the normal case (as the server closes when it's done sending). I did a quick perftest with AsyncWebServer and saw no significant performance difference.