[v0.10] fix: CloseWait with buffered data potentially causing a dead-lock#172
Open
Ddystopia wants to merge 1 commit intoquartiq:masterfrom
Open
[v0.10] fix: CloseWait with buffered data potentially causing a dead-lock#172Ddystopia wants to merge 1 commit intoquartiq:masterfrom
Ddystopia wants to merge 1 commit intoquartiq:masterfrom
Conversation
Member
|
This failed CI. Could you investigate. I'm happy to keep a release-0.10 stable sync branch around for these fixes.
|
Contributor
Author
|
@jordens it doesn't seem to be an issue with the code, but with the runner infrastructure. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
When broker sends FIN and socket enters CLOSE_WAIT, tcp socket return
PipeClosedto the minimq andconnection_diedis set totrue. But what happens next? Ifminimqis used assynclibrary,pollwill be called next andclient.update()will notice that connection died and issueTcpDisconnectedevent, triggering reconnect to the broker. But withasynccode, everypollis weighted and has a reason.smoltcpwill not issue anywakeanymore because the socket is inCLOSE_WAITstate (nothing can arrive to it), thus until the application tries to write something to mqtt,minimqwill not get polled, reconnect to the broker will not happen.Thus, the change is simple - before exiting from
poll, callupdateonce more in case connection broke and initiate reconnect.smoltcpor other implementation ofembedded_hal::TcpClientStackwill handle the rest.Alternatives:
asyncuser can make severalpollofminimqbut this is extremely fragile and doesn't scale, not even talking about the waste.Additionally, I made a simple refactor, as no one will expect
if self.socket_was_closed()to mutate something. I split it into a getter and aresetmethod.