fix: do a best-effort transmit on connection close#625
fix: do a best-effort transmit on connection close#625colinmarc wants to merge 1 commit inton0-computer:mainfrom
Conversation
matheus23
left a comment
There was a problem hiding this comment.
Thank you for looking into this @colinmarc :)
Before we put in more work, I need to check back with @flub whether our ideas in n0-computer/iroh#4201 are sound & desirable.
Other than that:
- This needs a test! Ideally one that sets up a
Runtimesimilar to the one we're using in iroh: Most importantly one that uses aTaskTrackerand fairly aggressively closes all tasks (in this case those will be the connection and endpoint drivers). - Rather than driving the transmit in
close, I'd like to drive the transmit only when theConnectionDriveris dropped. Otherwise I worry thedrive_transmitfrom the connection driver and theclosecall can get in each others way. I think there's an invariant that the connection driver is the only thing that callsdrive_transmitand it never misses the consecutive calls to that function. The right place for callingdrive_transmitmight be in theimpl Drop for ConnectionRefright after theconn.implicit_close(..).
No worries, I just wanted to have something concrete to discuss :) This is only half of a workaround for that issue anyway.
That makes sense! Moved it to the drop for |
If we're shutting down ungracefully, we can make a best-effort attempt to write the CONNECTION_CLOSE to the socket and notify the peer. If we're in the middle of graceful shutdown, it doesn't hurt, either.
Description
If we're shutting down ungracefully, we can make a best-effort attempt to write the CONNECTION_CLOSE to the socket and notify the peer. If we're in the middle of graceful shutdown, it doesn't hurt, either.
This can be taken advantage of by callers to do a quicker shutdown if they know the drain period isn't necessary. Discussion here: n0-computer/iroh#4201