Fix an infinite read loop with SRV record resolution on windows#25672
Merged
apolcyn merged 1 commit intogrpc:masterfrom Mar 10, 2021
Merged
Fix an infinite read loop with SRV record resolution on windows#25672apolcyn merged 1 commit intogrpc:masterfrom
apolcyn merged 1 commit intogrpc:masterfrom
Conversation
markdroth
approved these changes
Mar 10, 2021
Contributor
Author
|
interop cloud to cloud: #25679 |
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.
Tentative fix for #25654
One effect of the simplification in #25105 was that it changed the c-ares resolver to invoke
RegisterOnReadableLockedon all active fd's also now when SRV records are resolved. Notably, it does this from a callback that is invoked from the c-ares library during a call toares_process, and it also clears the readable_registered_ flag before doing this. After thisares_processcall completes, we check if there are still more bytes to read on the socket and then continue looping on ares_process if so.On Windows,
RegisterOnReadableLockedpre-allocates space forread_buf_to read in bytes asynchronously viaRecvFrom. Data is actually filled intoread_buf_only when theRecvFromcall completes and theOnIocpReadableLockedcallback is invoked. So because we are callingRegisterForOnReadableLockedfrom a callback invoked fromares_process, whenares_processreturns,read_buf_has a non-zero length but doesn't actually have any readable data. Thus the loop where we continue callingares_processso long asIsStillReadableLockedreturns true will never finish.read_buf_has_data_is set true when we read in data fromRecvFrom, and is then cleared after c-ares reads all received bytes out of it (this is the proper flag to check if there are still bytes remaining to be read).