fix(tls): potential deadlock in StdSocket::poll_ready()#4251
Merged
Conversation
Collaborator
Author
|
@jcreekmore can you try this branch and see if it also eliminates the issue? I changed |
|
It also eliminates the issue. I technically didn't run this branch, but I cherry-picked the change on top of 0.8.6 so that I didn't have to worry about pulling in any other changes that have occurred in the interim. |
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.
Does your PR solve an issue?
Changes
StdSocket::poll_ready()to schedule wakeups for both reads and writes where applicable, and return if either direction is ready, not necessarily both.Previously, if the TLS code, e.g.
rustls::Connection::complete_io()tried to both read and write on the socket,poll_ready()would wait for the connection to be ready in both directions. This was prone to deadlocking if the server-side was waiting to receive more data before it sent any, e.g. it was waiting for us to write a fullExecutepacket so it could start executing a query and feeding back results.poll_ready()now returnsReadyif either direction is ready even if the other direction is blocked, letting the TLS implementation do as much I/O as possible before going to sleep and hopefully preventing deadlocks of this kind.fixes #4248
This likely fixes a number of other hang/deadlock-related issues as well, but I'd need to find them.
Is this a breaking change?
No.