Reset() private method

private Reset ( ThreadPoolBoundHandle boundHandle, ulong requestId, uint size ) : void
boundHandle System.Threading.ThreadPoolBoundHandle
requestId ulong
size uint
return void
        internal uint QueueBeginGetContext()
        {
            uint statusCode = Interop.HttpApi.ERROR_SUCCESS;

            while (true)
            {
                if (NetEventSource.Log.IsEnabled())
                {
                    NetEventSource.Info(this, $"Calling Interop.HttpApi.HttpReceiveHttpRequest RequestId: {_requestContext.RequestBlob->RequestId}Buffer:0x {((IntPtr)_requestContext.RequestBlob).ToString("x")} Size: {_requestContext.Size}");
                }
                uint bytesTransferred = 0;
                HttpListenerSession listenerSession = (HttpListenerSession)AsyncObject;
                statusCode = Interop.HttpApi.HttpReceiveHttpRequest(
                    listenerSession.RequestQueueHandle,
                    _requestContext.RequestBlob->RequestId,
                    (uint)Interop.HttpApi.HTTP_FLAGS.HTTP_RECEIVE_REQUEST_FLAG_COPY_BODY,
                    _requestContext.RequestBlob,
                    _requestContext.Size,
                    &bytesTransferred,
                    _requestContext.NativeOverlapped);

                if (NetEventSource.Log.IsEnabled())
                {
                    NetEventSource.Info(this, "Call to Interop.HttpApi.HttpReceiveHttpRequest returned:" + statusCode);
                }
                if (statusCode == Interop.HttpApi.ERROR_INVALID_PARAMETER && _requestContext.RequestBlob->RequestId != 0)
                {
                    // we might get this if somebody stole our RequestId,
                    // set RequestId to 0 and start all over again with the buffer we just allocated
                    _requestContext.RequestBlob->RequestId = 0;
                    continue;
                }
                else if (statusCode == Interop.HttpApi.ERROR_MORE_DATA)
                {
                    // the buffer was not big enough to fit the headers, we need
                    // to read the RequestId returned, allocate a new buffer of the required size
                    _requestContext.Reset(listenerSession.RequestQueueBoundHandle, _requestContext.RequestBlob->RequestId, bytesTransferred);
                    continue;
                }
                else if (statusCode == Interop.HttpApi.ERROR_SUCCESS && HttpListener.SkipIOCPCallbackOnSuccess)
                {
                    // IO operation completed synchronously - callback won't be called to signal completion.
                    IOCompleted(this, statusCode, bytesTransferred);
                }
                break;
            }
            return(statusCode);
        }
        internal uint QueueBeginGetContext()
        {
            uint statusCode = UnsafeNclNativeMethods.ErrorCodes.ERROR_SUCCESS;

            while (true)
            {
                GlobalLog.Print("ListenerAsyncResult#" + ValidationHelper.HashString(this) + "::QueueBeginGetContext() calling UnsafeNclNativeMethods.HttpApi.HttpReceiveHttpRequest RequestId:" + m_RequestContext.RequestBlob->RequestId + " Buffer:0x" + ((IntPtr)m_RequestContext.RequestBlob).ToString("x") + " Size:" + m_RequestContext.Size.ToString());
                (AsyncObject as HttpListener).EnsureBoundHandle();
                uint bytesTransferred = 0;
                statusCode = UnsafeNclNativeMethods.HttpApi.HttpReceiveHttpRequest(
                    (AsyncObject as HttpListener).RequestQueueHandle,
                    m_RequestContext.RequestBlob->RequestId,
                    (uint)UnsafeNclNativeMethods.HttpApi.HTTP_FLAGS.HTTP_RECEIVE_REQUEST_FLAG_COPY_BODY,
                    m_RequestContext.RequestBlob,
                    m_RequestContext.Size,
                    &bytesTransferred,
                    m_RequestContext.NativeOverlapped);

                GlobalLog.Print("ListenerAsyncResult#" + ValidationHelper.HashString(this) + "::QueueBeginGetContext() call to UnsafeNclNativeMethods.HttpApi.HttpReceiveHttpRequest returned:" + statusCode);
                if (statusCode == UnsafeNclNativeMethods.ErrorCodes.ERROR_INVALID_PARAMETER && m_RequestContext.RequestBlob->RequestId != 0)
                {
                    // we might get this if somebody stole our RequestId,
                    // set RequestId to 0 and start all over again with the buffer we just allocated
                    //
                    m_RequestContext.RequestBlob->RequestId = 0;
                    continue;
                }
                else if (statusCode == UnsafeNclNativeMethods.ErrorCodes.ERROR_MORE_DATA)
                {
                    // the buffer was not big enough to fit the headers, we need
                    // to read the RequestId returned, allocate a new buffer of the required size
                    m_RequestContext.Reset(m_RequestContext.RequestBlob->RequestId, bytesTransferred);
                    continue;
                }
                else if (statusCode == UnsafeNclNativeMethods.ErrorCodes.ERROR_SUCCESS &&
                         HttpListener.SkipIOCPCallbackOnSuccess)
                {
                    // IO operation completed synchronously - callback won't be called to signal completion.
                    IOCompleted(this, statusCode, bytesTransferred);
                }
                break;
            }
            return(statusCode);
        }