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

Wait for serverTask before asserting IsCompletedSuccessfully #79071

Merged
merged 2 commits into from
Dec 2, 2022

Conversation

jozkee
Copy link
Member

@jozkee jozkee commented Dec 1, 2022

Fixes #79052.

Most likely serverTask not always finishes on time, so adding Wait(10_000) before checking the property.
That's what we do on the else branch.

if (serverPipeOptions == PipeOptions.None && clientPipeOptions == PipeOptions.CurrentUserOnly && clientDirection == PipeDirection.In)
{
// When CurrentUserOnly is only on client side and asks for ReadOnly access, the connection is not rejected
// but we get the UnauthorizedAccessException on the client regardless.
Assert.True(serverTask.IsCompletedSuccessfully);
}
else
{
// Server is expected to not have received any request.
cts.Cancel();
AggregateException ex = Assert.Throws<AggregateException>(() => serverTask.Wait(10_000));

@ghost
Copy link

ghost commented Dec 1, 2022

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

Issue Details

Fixes #79052.

Most likely serverTask not always finishes on time, so adding Wait(10_000) before checking the property.
That's what we do on the else branch.

if (serverPipeOptions == PipeOptions.None && clientPipeOptions == PipeOptions.CurrentUserOnly && clientDirection == PipeDirection.In)
{
// When CurrentUserOnly is only on client side and asks for ReadOnly access, the connection is not rejected
// but we get the UnauthorizedAccessException on the client regardless.
Assert.True(serverTask.IsCompletedSuccessfully);
}
else
{
// Server is expected to not have received any request.
cts.Cancel();
AggregateException ex = Assert.Throws<AggregateException>(() => serverTask.Wait(10_000));

Author: Jozkee
Assignees: -
Labels:

area-System.IO

Milestone: -

Copy link
Member

@adamsitnik adamsitnik left a comment

Choose a reason for hiding this comment

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

PTAL at my comment, IMO we could use ManualResetEvent here and make it more reliable.

Copy link
Member

@adamsitnik adamsitnik left a comment

Choose a reason for hiding this comment

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

LGTM, thank you @jozkee !

@adamsitnik
Copy link
Member

For some reason the CI did not start, I am going to close and re-open.

image

@adamsitnik adamsitnik closed this Dec 2, 2022
@adamsitnik adamsitnik reopened this Dec 2, 2022
@jozkee jozkee merged commit 8e07dd4 into dotnet:main Dec 2, 2022
@jozkee jozkee deleted the named_pipe_test branch December 2, 2022 17:18
@ghost ghost locked as resolved and limited conversation to collaborators Jan 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
3 participants