Skip to content

Conversation

@rzikm
Copy link
Member

@rzikm rzikm commented Jul 22, 2022

Fixes #58072.

This PR makes sure the Http3RequestStream is removed from _activeRequests immediately after the request is read completely or aborted. This allows closing the Http3Connection before all the response streams are disposed.

@ghost ghost added the area-System.Net.Http label Jul 22, 2022
@ghost ghost assigned rzikm Jul 22, 2022
@ghost
Copy link

ghost commented Jul 22, 2022

Tagging subscribers to this area: @dotnet/ncl
See info in area-owners.md if you want to be subscribed.

Issue Details

Fixes #58072.

This PR makes sure the Http3RequestStream is removed from _activeRequests immediately after the request is read completely or aborted. This allows closing the Http3Connection before all the response streams are disposed.

Author: rzikm
Assignees: -
Labels:

area-System.Net.Http

Milestone: -

@rzikm rzikm requested a review from a team July 22, 2022 11:19
@rzikm
Copy link
Member Author

rzikm commented Jul 22, 2022

/azp run runtime-libraries-coreclr outerloop

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@ManickaP
Copy link
Member

Do we have any test coverage for the scenario Geoff described in the orig issue? He mentions GetAsync_CancelDuringResponseBodyReceived_Unbuffered_TaskCanceledQuickly but I'm wondering how come it didn't cause problems before this change (if it even runs)

@rzikm
Copy link
Member Author

rzikm commented Jul 22, 2022

Do we have any test coverage for the scenario Geoff described in the orig issue? He mentions GetAsync_CancelDuringResponseBodyReceived_Unbuffered_TaskCanceledQuickly but I'm wondering how come it didn't cause problems before this change (if it even runs)

The test Geoff mentioned is running for Http3, I removed the using which was put there because of HTTP3 so the scenario is exercised. However, the only difference with this PR is that the test does not run for 1m but for 300ms. Do you think we should add a time limit (say, 30s)?

@ManickaP
Copy link
Member

Do you think we should add a time limit (say, 30s)?

Sounds good. And if it causes any troubles we can just remove it.

@rzikm
Copy link
Member Author

rzikm commented Jul 22, 2022

/azp run runtime-libraries-coreclr outerloop

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@rzikm
Copy link
Member Author

rzikm commented Jul 25, 2022

Test failure is #72756

@rzikm rzikm requested a review from ManickaP July 25, 2022 09:54
Comment on lines 1469 to 1475

private enum StreamCompletionState : byte
{
InProgress,
Completed,
Failed
}
Copy link
Member

Choose a reason for hiding this comment

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

Is this used?

}

_requestSendCompleted = true;
RemoveFromConnectionIfDone();
Copy link
Member

Choose a reason for hiding this comment

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

What happens in exceptional cases? Is it handled somehow differently? Same question for _responseRecvCompleted.

Copy link
Member Author

Choose a reason for hiding this comment

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

_responseRecvCompleted is set to true in HandleReadResponseContentException so it is set in exceptional cases too.

I moved _requestSendCompleted to a finally block to make sure it covers both successful and unsuccessful paths.

Comment on lines +59 to +60
private bool _requestSendCompleted;
private bool _responseRecvCompleted;
Copy link
Member

Choose a reason for hiding this comment

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

How does this differ from _responseDataPayloadRemaining and _requestContentLengthRemaining?
Just making sure we need these fields and cannot use something we already have.

Copy link
Member Author

Choose a reason for hiding this comment

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

_responseDataPayloadRemaining is only for the current DATA frame. _requestContentLengthRemaining seems to be usable.

Copy link
Member Author

Choose a reason for hiding this comment

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

Unfortunately, I think we need both actually because with plain _requestContentLengthRemaining I can't distinguish failed request sends.

@rzikm rzikm requested review from a team and ManickaP July 26, 2022 11:37
Copy link
Member

@ManickaP ManickaP left a comment

Choose a reason for hiding this comment

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

Thanks, LGTM.

@rzikm rzikm merged commit faebe45 into dotnet:main Jul 26, 2022
@karelz karelz added this to the 7.0.0 milestone Aug 7, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Sep 6, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HTTP3: Http3Stream is not removed from _activeRequests table until response Stream Dispose is called

3 participants