Skip to content
This repository was archived by the owner on Dec 18, 2018. It is now read-only.

Conversation

@cesarblum
Copy link
Contributor

@cesarblum cesarblum commented Jul 5, 2016

@cesarblum cesarblum force-pushed the cesarbs/econnreset-as-error branch from 4b960e1 to c42ab12 Compare July 6, 2016 23:28
@cesarblum
Copy link
Contributor Author

Rebased.

.UseUrls($"http://127.0.0.1:0")
.Configure(app => app.Run(context =>
{
return Task.FromResult(0);
Copy link
Member

Choose a reason for hiding this comment

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

We should also assert that context.Request.Body.ReadAsync fails with an IOException.

I think that SocketInputExtensions.ReadAsync and possibly a few other places will have to be updated to check if there is an error (possibly by calling SocketInput.GetResult()) in a thread-safe way before exiting due to RemoteIntakeFin being set.

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've opened #959 to address this.

var filteredWrites = testSink.Writes.Where(write => write.EventId.Id == connectionErrorEventId);
for (var i = 0; i < 10; i++)
{
System.Console.WriteLine(i);
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove call to Console.WriteLine()?

@cesarblum cesarblum force-pushed the cesarbs/econnreset-as-error branch from c42ab12 to 7b4a6ab Compare July 7, 2016 23:00

// Give it some time for the connection error log message to be logged
var filteredWrites = testSink.Writes.Where(write => write.EventId.Id == connectionErrorEventId);
for (var i = 0; i < 10; i++)
Copy link
Contributor

@mikeharder mikeharder Jul 9, 2016

Choose a reason for hiding this comment

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

I would make the test code itself wait forever (rather than only 500ms), then wrap the whole test in a call to Task.Run().TimeoutAfter() with a large timeout (say 10 seconds), so it fails if it exceeds the timeout for any reason.

@cesarblum cesarblum force-pushed the cesarbs/econnreset-as-error branch from 7b4a6ab to 122ea86 Compare July 11, 2016 22:52
@cesarblum
Copy link
Contributor Author

@halter73 Now handling error when checking for FIN.

}
}

private void ThrowOnConnectionError()
Copy link
Member

Choose a reason for hiding this comment

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

😞

Copy link
Member

Choose a reason for hiding this comment

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

@davidfowl You're now well-versed in this code. Do you have a better alternative?

Copy link
Member

Choose a reason for hiding this comment

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

Can we just use a Task instead?

Copy link
Member

Choose a reason for hiding this comment

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

I also like this idea @CesarBS.

@cesarblum cesarblum force-pushed the cesarbs/econnreset-as-error branch from ccd701a to ff13219 Compare July 13, 2016 01:35
@cesarblum
Copy link
Contributor Author

Updated to use TaskCompletionSource to combine FIN and error states, as suggested by @davidfowl.

private bool _consuming;
private bool _disposed;

private TaskCompletionSource<bool> _tcs = new TaskCompletionSource<bool>();
Copy link
Member

Choose a reason for hiding this comment

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

TaskCompletionSource<bool> implies Result is useful and might be false. Since it never will be, TaskCompletionSource<object> is probably better.

@halter73
Copy link
Member

:shipit:

@cesarblum
Copy link
Contributor Author

Updated tests:

  • Check type of InnerException inside caught IOException (@halter73 we get a UvException here, not a TaskCanceledException)
  • Add timeouts to WaitAsync calls on semaphores
  • Use custom test sink to look for expected log message on connection reset. With the previous approach there would sometimes be errors when calling Any() on the writes collection while it was being modified

@cesarblum
Copy link
Contributor Author

Had to change ThrowsOnReadAfterConnectionError to handle two possible exception types thrown on an attempt to read from an errored connection:

  • IOException: this was in the original test. We get one if ReadAsync is awaiting on SocketInput when the connection is aborted.
  • TaskCanceledException: this is the new one. We get one if ReadAsync is called by the time the connection has already been aborted after an error.

This is quite ugly. We should probably address this and have a single behavior, but I'd like it to be addressed as a separate task.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants