Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed invocation cancellation to correctly cancel the payload read #1640

Merged
merged 2 commits into from
Aug 19, 2022

Conversation

bentoi
Copy link
Contributor

@bentoi bentoi commented Aug 18, 2022

This PR fixes #1610 and adds tests for invocation cancellation.

@bentoi bentoi requested a review from bernardnormier August 18, 2022 16:20
Copy link
Member

@bernardnormier bernardnormier left a comment

Choose a reason for hiding this comment

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

Looks good except for the incorrect test.

Exception? completeException = null;
using var invocationCancelSource = CancellationTokenSource.CreateLinkedTokenSource(
Copy link
Member

Choose a reason for hiding this comment

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

Should we use "cts" like Microsoft frequently does in runtime? Could be invocationCts, _dispatchesAndInvocationsCts.

I grepped runtime for CancelSource and there is not a single match.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, let's do this in another PR to fix all our CTS names.

@@ -301,20 +298,12 @@ private protected override async ValueTask DisposeAsyncCore()
}
finally
{
if (completeException is not null)
if (completeException is not null && stream is not null)
Copy link
Member

Choose a reason for hiding this comment

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

I find this catch/catch/finally code weird, especially since the only purpose of the completeException variable is to feed it to the finally block.

Maybe we could instead use a helper local function void CompleteStreamAsync(Exception exception)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We use this optional exception catch/finally pattern is multiple places. I don't see why we would use a helper function here just because the finally block doesn't perform other cleanup.

To me, either we change all the code using this pattern to use a helper function for exception related cleanup or we stick to this pattern even in this case.

});
}

[Ignore("see issue #1638")]
Copy link
Member

Choose a reason for hiding this comment

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

The test is incorrect. If you want to keep reading the incoming request's payload after returning a response, you need to "detach" (swap) this payload.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll fix this in another PR.

@bentoi bentoi merged commit 67ff7de into icerpc:main Aug 19, 2022
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.

Invocation cancellation doesn't cancel the payload reading of payload writing
2 participants