Switch CRT HTTP sync client from pull-based body to push-based writeData#7001
Open
zoewangg wants to merge 8 commits into
Open
Switch CRT HTTP sync client from pull-based body to push-based writeData#7001zoewangg wants to merge 8 commits into
zoewangg wants to merge 8 commits into
Conversation
push-based HttpStreamBase.writeData() API to avoid potential deadlock issue when request body InputStream blocks.
Move stream lifecycle operations (writeData, incrementWindow, releaseConnection, closeConnection) from ResponseHandlerHelper into a dedicated CrtStreamHandler class. This separates header parsing from stream management and makes the shared stream guard explicit between the request executor and response handler. ResponseHandlerHelper now only handles response header parsing.
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.
Motivation and Context
AwsCrtHttpClientcan potentially deadlock when the request bodyInputStreamblocks on the CRT event loop thread. This can occur when a blocking stream (e.g., aBufferedInputStreamwrapping aResponseInputStream) is used as a request body and the read depends on the same event loop thread to deliver data.CrtRequestInputStreamAdapter.sendRequestBody()is invoked on the CRT event loop thread and callsInputStream.read(), which may block indefinitely. The CRT event loop must never block.Note that this applies to CRT sync HTTP client only and a follow up PR will be created to update async HTTP client
Modifications
HttpRequestBodyStream.sendRequestBody()model to the push-basedHttpStreamBase.writeData()API. The caller thread now writes the request body instead of the event loop thread.CrtRequestExecutor.execute()passesuseManualDataWrites=trueviaacquireStreamwhen the request has a body. Returns anExecutionResultexposing boththe stream future and response future.
AwsCrtHttpClient.CrtHttpRequest.call()waits for stream acquisition, writes the body from the caller thread viastream.writeData(), then waits for theresponse.
CrtRequestInputStreamAdapter(no longer used).aws-crtdependency forwriteDataandacquireStream(request, handler, useManualDataWrites)APIs.Testing
http-clients/aws-crt-clientpass.Types of changes
Checklist
mvn installsucceedsscripts/new-changescript and following the instructions. Committhe new file created by the script in
.changes/next-releasewith your changes.LaunchChangelog
License