Skip to content

AbortStream method to Http1StreamManager and ensure streams are released to connection pool#1002

Open
TingDaoK wants to merge 12 commits into
mainfrom
abort-strema
Open

AbortStream method to Http1StreamManager and ensure streams are released to connection pool#1002
TingDaoK wants to merge 12 commits into
mainfrom
abort-strema

Conversation

@TingDaoK

@TingDaoK TingDaoK commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Issue #, if available:

Description of changes:
Otherside of the original PR, which already be well described in the original description.

  • fixed couple test issue from the original PR
  • Added comments about the requirement to activate the http/1.1 stream before using it.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@TingDaoK TingDaoK marked this pull request as ready for review July 7, 2026 00:06
streamHandler.onResponseComplete(stream, e.errorCode);
/* Release the connection back */
connManager.releaseConnection(conn);
if (connectionReleased.compareAndSet(false, true)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we allow multiple release of connections natively?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we do allow it. Why should connection be released exactly once?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it actually ends up with httpClientConnectionReleaseManaged in the binding, it avoids the race between multiple threads trying to release the same connection back to the pool.

aws_http_connection_manager_release_connection cannot be invoked twice.
And the binding level is not thread safe.

*
* <p><b>Important:</b> Operations on the stream (such as {@code cancel()}) must only be invoked
* after {@code activate()} has been called. If {@code cancel()} is called before activate, it
* is a no-op — the stream will still proceed normally once activate runs, which may lead to

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a bit more of a philosophical question, but should activate on cancelled stream really be a noop? should it not activate the stream at all?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, yeah, the activate on the cancelled stream should result in no-op.
But, we kind designed the cancel on an unactivated stream to be a no-op. And without altering any state of the stream. https://github.com/awslabs/aws-c-http/blob/main/include/aws/http/request_response.h#L1222-L1232

If we keep that behavior to basically ignore the cancel, then it still makes more sense to let activate do its thing.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in retrospect was it the correct choice to design it this way? not saying we should change it now.
cancel being a noop for non-active connection seems to bring more problems that we have to work around.

@TingDaoK TingDaoK changed the title Abort stream AbortStream method to Http1StreamManager and ensure streams are released to connection pool Jul 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants