-
Notifications
You must be signed in to change notification settings - Fork 522
Conversation
Hi @Tragetaschen, I'm your friendly neighborhood Microsoft Open Technologies, Inc. Pull Request Bot (You can call me MSOTBOT). Thanks for your contribution! The agreement was validated by Microsoft Open Technologies, Inc. and real humans are currently evaluating your PR. TTYL, MSOTBOT; |
Wow, that's a lot of work! The individual commits are very helpful and they sound like good ideas based on the descriptions. We'll take a closer look soon. Thank you very much! |
0fb3e9b
to
c93c029
Compare
As a final step (well, let's see about that):
Since they have to clean both loop resource as well as the unmanaged memory, the SafeHandle pattern does not really work: By the time the Finalizer runs, the loop might have been long brought down and posting to it won't work. The new base class implements a working UvHandle pattern and warns when a finalizer does the cleanup (I don't get the warning). |
Indirectly, I know that OSx won't work, but it's close. I have modified my Linux environment so it looks similar to how OSx will behave (basically removed libuv* from /usr/lib64 and placed the files in various folders). The reason it worked on Linux so far is that mono is quite smart with I'll revert to the manual binding :-/ |
{ | ||
IsDarwin = PlatformApis.IsDarwin(); | ||
#if ASPNETCORE50 | ||
return true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While this is true now, it won't be true in the future... what would be the correct code once Core CLR runs on non-Windows?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question.
This code is the same as before, I just took it as is. However, I spent a few thoughts and decided I don't know enough to fix it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah OK we'll figure this out in the future, then.
3b1443e
to
1ee6990
Compare
private static void WriteCallback(UvWriteReq req, int status, Exception error, object state) | ||
{ | ||
((ThisWriteReq)state).OnWrite(req, status, error); | ||
} | ||
|
||
SocketOutput _self; | ||
ArraySegment<byte> _buffer; | ||
byte[] _buffer; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only code path into the Contextualize currently creates a copy of the incoming ArraySegment. I figured I can simplify the code down to the P/Invoke.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That part of the server hasn't been optimized at all really (which is why it's copying the array segment every time) - so I wouldn't worry too much about fixing that code path before it's been fine-tuned.
|
I will now stop shuffeling code around :) |
846221c
to
867582f
Compare
@lodejard can you try this out locally and merge? |
I'm close to fixing most of the bugs I found so far (see the -beta2 branch in my fork). For stability reasons, I'd prefer that additional work to be included |
d5baac8
to
b83615f
Compare
I'm not quite convinced of the last commit. Not that I couldn't defend its practical correctness, but some code paths down the The leaking SignalR connections currently trigger a |
I've done a fair amount of testing including |
There was a race between closing the socket client-wise on the one hand and still writing from the application's end. The write request could throw an Instead of catching this exception, I changed the |
d5cc00e
to
b449d77
Compare
When a connection with an active write request is closed, the write request's callback gets -UV_ECANCELED as error code. This is now handled as an expected error. |
…writing resulting in an ObjectDisposedException that would bring down the loop
handling for well-formed requests.
73c3fb8
to
05e6404
Compare
Sure |
{ | ||
KestrelTrace.Log.ConnectionReadFin(_connectionId); | ||
SocketInput.RemoteIntakeFin = true; | ||
_socket.ReadStop(); | ||
if (status != -4095) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you define a descriptive constant for this? The same goes for the ones above.
@Tragetaschen, Thanks for signing the contribution license agreement so quickly! Actual humans will now validate the agreement and then evaluate the PR. |
Watching last week's Community Standup made me really, really sad :( |
This PR cleans up large portions of the P/Invoke handling of Kestrel to libuv. I know these are a lot of changes, but I have kept the single commits for easier following.
The highlights are:
UseDllImport
and Mono'sDllMap
feature instead of manually loading and binding a platform-specific librarySafeHandle
s now do all the required allocation work in their constructorsunsafe
I have tested on both Windows and Linux, but could not do so on a Mac simply because I don't have access to one. My test setup included a web application with an active SignalR connection. I was not able to reproduce any of the shutdown issues again (yet?)