Repository navigation
Fix incorrect exception thrown in HttpResponseStream.Write for a closed connection - #19219
Conversation
| public static void WaitForSocketShutdown(Socket socket) | ||
| { | ||
| while (SocketConnected(socket)); | ||
| if (PlatformDetection.IsWindows) |
There was a problem hiding this comment.
These shenanigans are needed because the native implementation is dumb and doesn't know when a socket is closed, but the managed implementation uses sockets directly so this is fine
There was a problem hiding this comment.
Oh, and the old WaitForSocketShutdown implementation hanged forever.
|
Looks like one of the tests is having trouble on macOS: |
This smells like a race condition again, so I'll need to investigate this more. |
Potentially, though "race condition" generally isn't my first instinct when the same test fails on all legs for a specific platform and only that platform. |
|
I only mentioned race condition as I thought it's possibly similar to https://github.com/dotnet/corefx/issues/18188 But granted, it's odd that it's only OSX failing. I don't know enough about the S.Net or macos networking stack to say why, but I've pushed a commit that may fix this, or may hang forever if it has the same behaviour as Linux |
|
@stephentoub I think @hughbe is stumped by the osx failures. I'm guessing he doesn't have a mac to debug. any thoughts? |
|
@dotnet-bot test Innerloop OSX10.12 Debug x64 Build and Test please |
|
@stephentoub you got your logs |
|
Friendly ping @stephentoub so I have time to potentially fix this before ZBB |
|
@dotnet-bot test Innerloop OSX10.12 Release x64 Build and Test (why not) |
|
@hughbe, to avoid holding up the whole PR, go ahead and disable this test on macOS. |
|
Sure. Can't do that until tomorrow but I think it'll be OK as I'm 15rs forward or so, so this can still make XBB. Do you want me to make an issue? |
I'll take care of it. |
|
@dotnet-bot test Innerloop netfx Windows_NT Debug x86 Build and Test please |
| while (SocketConnected(socket)); | ||
| if (PlatformDetection.IsWindows || PlatformDetection.IsOSX) | ||
| { | ||
| socket.Shutdown(SocketShutdown.Both); |
There was a problem hiding this comment.
Why is the Shutdown call not done on Linux?
There was a problem hiding this comment.
@hughbe has commented before on previous commit "These shenanigans are needed because the native implementation is dumb and doesn't know when a socket is closed, but the managed implementation uses sockets directly so this is fine". I think he hypothesizes, that on windows we call into the native apis which does the connections, whereas in managed httplistener we use the socket apis, so the close socket behavior is taking long on windows to terminate connection on other side. But we can unify code and have shutdown and the while check on all platforms, i guess he just did the special case on the platform that was failing consistently.
There was a problem hiding this comment.
We use the managed implementation on macOS as well, so that doesn't explain why the check is for IsWindows || IsOSX.
There was a problem hiding this comment.
On my Ubuntu VM these tests all hung without this code. I added OSX because I suspected that's what caused the OSX failures. (I was wrong)
I'm also now a bit nervous about these tests, as i dont know if they're going to fail in the CI due to timing etc
I've ran the tests on windows 1000 times and nothing failed but I'm not sure about ubuntu so I will test that before merging. Seems like the CI hates me
There was a problem hiding this comment.
Seems like the CI hates me
Sometimes we all feel that way :)
There was a problem hiding this comment.
I'd have expected on all platforms you could do:
socket.Shutdown(SocketShutdown.Both);
while (SocketConnected(socked));
socket.Close();I don't have a $2000 block of very well brushed aluminium to test this on. This might hang, or it might work.
|
@dotnet-bot test outerloop netfx Windows_NT Debug |
|
@ericstj, @erozenfeld illink seg faulted: |
|
@dotnet-bot test Innerloop Ubuntu16.04 arm Debug Cross Build please (seg fault in illink) |
|
@swaroop-sridhar @sbomer @russellhadley |
|
I'll take a look, I'm trying to repro the build failure locally now. |
|
All of the recent runs have passed in this leg: I can try to take down a jenkins node and repro the failure -- but I doubt if it'll repro. |
Contributes to #18128