Repository navigation
Conversation
…ts are closed When a client or the backend broker drops a connection or disconnects, calling close() without shutdown(SHUT_RDWR) leaves the peer relay thread blocked in recv() on Linux/POSIX sockets, preventing the connection from closing cleanly and evicting dropped clients. Calling endpoint.shutdown(socket.SHUT_RDWR) unblocks blocking peer recvs and sends TCP FIN/RST immediately. Fixes Python-roborock#262
This branch has not been deployed
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.
Summary
When a client or Mosquitto drops a connection (e.g. Client has exceeded timeout, disconnecting), calling close() on both sockets in _relay() or _close_conn_endpoints() does not interrupt a concurrent blocking
ecv(4096) in the other relay thread on POSIX/Linux systems. This prevents the proxy from cleanly tearing down the connection, sending a FIN/RST packet, and logging [conn N] closed.
Adding endpoint.shutdown(socket.SHUT_RDWR) before endpoint.close() immediately interrupts any blocked
ecv() calls and delivers TCP FIN/RST to both the vacuum/client and the backend broker, allowing the relay threads to join cleanly and the connection to be deregistered.
Changes
Resolves #262