private void RegisterForDisconnectNotification(ulong connectionId, ref DisconnectAsyncResult disconnectResult) { Debug.Assert(disconnectResult == null); try { if (NetEventSource.IsEnabled) NetEventSource.Info(this, "Calling Interop.HttpApi.HttpWaitForDisconnect"); DisconnectAsyncResult result = new DisconnectAsyncResult(this, connectionId); uint statusCode = Interop.HttpApi.HttpWaitForDisconnect( _requestQueueHandle, connectionId, result.NativeOverlapped); if (NetEventSource.IsEnabled) NetEventSource.Info(this, "Call to Interop.HttpApi.HttpWaitForDisconnect returned:" + statusCode); if (statusCode == Interop.HttpApi.ERROR_SUCCESS || statusCode == Interop.HttpApi.ERROR_IO_PENDING) { // Need to make sure it's going to get returned before adding it to the hash. That way it'll be handled // correctly in HandleAuthentication's finally. disconnectResult = result; DisconnectResults[connectionId] = disconnectResult; } if (statusCode == Interop.HttpApi.ERROR_SUCCESS && HttpListener.SkipIOCPCallbackOnSuccess) { // IO operation completed synchronously - callback won't be called to signal completion. result.IOCompleted(statusCode, 0, result.NativeOverlapped); } } catch (Win32Exception exception) { uint statusCode = (uint)exception.NativeErrorCode; if (NetEventSource.IsEnabled) NetEventSource.Info(this, "Call to Interop.HttpApi.HttpWaitForDisconnect threw, statusCode:" + statusCode); } }
private void RegisterForDisconnectNotification(ulong connectionId, ref DisconnectAsyncResult disconnectResult) { GlobalLog.Assert(disconnectResult == null, "HttpListener#{0}::RegisterForDisconnectNotification()|Called with a disconnectResult.", ValidationHelper.HashString(this)); try { GlobalLog.Print("HttpListener#" + ValidationHelper.HashString(this) + "::RegisterForDisconnectNotification() calling UnsafeNclNativeMethods.HttpApi.HttpWaitForDisconnect"); DisconnectAsyncResult result = new DisconnectAsyncResult(this, connectionId); EnsureBoundHandle(); uint statusCode = UnsafeNclNativeMethods.HttpApi.HttpWaitForDisconnect( m_RequestQueueHandle, connectionId, result.NativeOverlapped); GlobalLog.Print("HttpListener#" + ValidationHelper.HashString(this) + "::RegisterForDisconnectNotification() call to UnsafeNclNativeMethods.HttpApi.HttpWaitForDisconnect returned:" + statusCode); if (statusCode == UnsafeNclNativeMethods.ErrorCodes.ERROR_SUCCESS || statusCode == UnsafeNclNativeMethods.ErrorCodes.ERROR_IO_PENDING) { // Need to make sure it's going to get returned before adding it to the hash. That way it'll be handled // correctly in HandleAuthentication's finally. disconnectResult = result; DisconnectResults[connectionId] = disconnectResult; } if (statusCode == UnsafeNclNativeMethods.ErrorCodes.ERROR_SUCCESS && HttpListener.SkipIOCPCallbackOnSuccess) { // IO operation completed synchronously - callback won't be called to signal completion. result.IOCompleted(statusCode, 0, result.NativeOverlapped); } } catch (Win32Exception exception) { uint statusCode = (uint) exception.NativeErrorCode; GlobalLog.Print("HttpListener#" + ValidationHelper.HashString(this) + "::RegisterForDisconnectNotification() call to UnsafeNclNativeMethods.HttpApi.HttpWaitForDisconnect threw. statusCode:" + statusCode); } }