Example #1
0
        private HttpWorkerRequest DequeueRequest(bool localOnly)
        {
            Object wr = null;

            if (_count > 0)
            {
                lock (this) {
                    if (_localQueue.Count > 0)
                    {
                        wr = _localQueue.Dequeue();
                        _count--;
                    }
                    else if (!localOnly && _externQueue.Count > 0)
                    {
                        wr = _externQueue.Dequeue();
                        _count--;
                    }
                }
                if (wr != null)
                {
                    PerfCounters.DecrementGlobalCounter(GlobalPerfCounter.REQUESTS_QUEUED);
                    PerfCounters.DecrementCounter(AppPerfCounter.REQUESTS_IN_APPLICATION_QUEUE);
                }
            }

            return((HttpWorkerRequest)wr);
        }
Example #2
0
        // Fully releases all managed resources associated with this request, including
        // the HttpContext, WebSocketContext, principal, worker request, etc.
        public void Destroy()
        {
            Debug.Trace("RootedObjects", "Destroy");

            // 'isDestroying = true' means that we'll release the implicit 'this' ref in _requestActivityIdRefCount
            using (WithinTraceBlock(isDestroying: true)) {
                try {
                    ReleaseHttpContext();
                    ReleaseWebSocketPipeline();
                    ReleaseWorkerRequest();
                    ReleasePrincipal();

                    // need to raise OnPipelineCompleted outside of the ThreadContext so that HttpContext.Current, User, etc. are unavailable
                    RaiseOnPipelineCompleted();

                    PerfCounters.DecrementCounter(AppPerfCounter.REQUESTS_EXECUTING);
                }
                finally {
                    if (_handle.IsAllocated)
                    {
                        _handle.Free();
                    }
                    Pointer = IntPtr.Zero;
                    HttpRuntime.DecrementActivePipelineCount();

                    AspNetEventSource.Instance.RequestCompleted();
                }
            }
        }
        private HttpWorkerRequest DequeueRequest(bool localOnly)
        {
            HttpWorkerRequest wr = null;

            while (_count > 0)
            {
                lock (this) {
                    if (_localQueue.Count > 0)
                    {
                        wr = (HttpWorkerRequest)_localQueue.Dequeue();
                        _count--;
                    }
                    else if (!localOnly && _externQueue.Count > 0)
                    {
                        wr = (HttpWorkerRequest)_externQueue.Dequeue();
                        _count--;
                    }
                }

                if (wr == null)
                {
                    break;
                }
                else
                {
                    PerfCounters.DecrementGlobalCounter(GlobalPerfCounter.REQUESTS_QUEUED);
                    PerfCounters.DecrementCounter(AppPerfCounter.REQUESTS_IN_APPLICATION_QUEUE);
                    if (EtwTrace.IsTraceEnabled(EtwTraceLevel.Information, EtwTraceFlags.Infrastructure))
                    {
                        EtwTrace.Trace(EtwTraceType.ETW_TYPE_REQ_DEQUEUED, wr);
                    }

                    if (!CheckClientConnected(wr))
                    {
                        HttpRuntime.RejectRequestNow(wr, true);
                        wr = null;

                        PerfCounters.IncrementGlobalCounter(GlobalPerfCounter.REQUESTS_DISCONNECTED);
                        PerfCounters.IncrementCounter(AppPerfCounter.APP_REQUEST_DISCONNECTED);
                    }
                    else
                    {
                        break;
                    }
                }
            }

            return(wr);
        }
        private HttpWorkerRequest DequeueRequest(bool localOnly)
        {
            HttpWorkerRequest workerRequest = null;

            while (this._count > 0)
            {
                lock (this)
                {
                    if (this._localQueue.Count > 0)
                    {
                        workerRequest = (HttpWorkerRequest)this._localQueue.Dequeue();
                        this._count--;
                    }
                    else if (!localOnly && (this._externQueue.Count > 0))
                    {
                        workerRequest = (HttpWorkerRequest)this._externQueue.Dequeue();
                        this._count--;
                    }
                }
                if (workerRequest == null)
                {
                    return(workerRequest);
                }
                PerfCounters.DecrementGlobalCounter(GlobalPerfCounter.REQUESTS_QUEUED);
                PerfCounters.DecrementCounter(AppPerfCounter.REQUESTS_IN_APPLICATION_QUEUE);
                if (EtwTrace.IsTraceEnabled(4, 1))
                {
                    EtwTrace.Trace(EtwTraceType.ETW_TYPE_REQ_DEQUEUED, workerRequest);
                }
                if (this.CheckClientConnected(workerRequest))
                {
                    return(workerRequest);
                }
                HttpRuntime.RejectRequestNow(workerRequest, true);
                workerRequest = null;
                PerfCounters.IncrementGlobalCounter(GlobalPerfCounter.REQUESTS_DISCONNECTED);
                PerfCounters.IncrementCounter(AppPerfCounter.APP_REQUEST_DISCONNECTED);
            }
            return(workerRequest);
        }
Example #5
0
 public void DecrementCounter(AppPerfCounter counter)
 {
     PerfCounters.DecrementCounter(counter);
 }