-
Notifications
You must be signed in to change notification settings - Fork 334
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
Request.CallCancelled is not set when client disconnects too fast #141
Comments
Interesting. That behavior is OS specific (Win8+), what OS are you running? See http://referencesource.microsoft.com/#System/net/System/Net/HttpListener.cs,296 |
Hi @Tratcher, thank you for replying. Windows 10. And the response is exactly NativeMethods.HttpErrors.NO_ERROR. It is saying that:
So we do call it in async way(we provide the callback) and they say it should always return ERROR_IO_PENDING. Which means a callback will be called. but if we receive NO_ERROR - it means the overlapped operation is done, hence callback will not be called. Btw, I know the case is very rare(client disconnection before we subscribe for the callback), even though it's a subject for a memory leak - since token will never be removed from the dictionary. |
And another thing regarding the code you sent. This code sample is on asp.net core. In katana this condition check is missing. |
A quote from here: Synchronization and Overlapped Input and Output
So in our case we do receive NO_ERROR, which means async operation we were asking for finished in a synchronous way. |
Request.CallCancelled cancellation token is never signaled if a client disconnects before this cancellation observed.
Bellow you can find an example which imitates client's disconnection.
Case 1: we observe(access it) the Request.CallCancelled before client disconnects
Case 2: we observe(access it) the Request.CallCancelled when client already gone
It seems the problem is somewhere here:
Client already gone by the time we are subscribing for the disconnection event. Subscription itself doesn't not return any error code, but the callback never called.
The text was updated successfully, but these errors were encountered: