// internal void Abort() { // if _CanTakeNewRequest==true we should not be holding any cache stream // Also we check on Abort() reentrancy this way. if (_CanTakeNewRequest) { return; } // in case of abnormal termination this will release cache entry sooner than does it's finalizer Stream stream = _ResponseStream; if (stream != null) { try { if (Logging.On) { Logging.PrintWarning(Logging.RequestCache, SR.GetString(SR.net_log_cache_closing_cache_stream, "CacheProtocol#" + this.GetHashCode().ToString(NumberFormatInfo.InvariantInfo), "Abort()", stream.GetType().FullName, _Validator.CacheKey)); } ICloseEx closeEx = stream as ICloseEx; if (closeEx != null) { closeEx.CloseEx(CloseExState.Abort | CloseExState.Silent); } else { stream.Close(); } } catch (Exception e) { if (NclUtilities.IsFatal(e)) { throw; } if (Logging.On) { Logging.PrintError(Logging.RequestCache, SR.GetString(SR.net_log_cache_exception_ignored, "CacheProtocol#" + this.GetHashCode().ToString(NumberFormatInfo.InvariantInfo), "stream.Close()", e.ToString())); } } } Reset(); }
internal void Abort() { Stream connectStream = this.m_ConnectStream; ICloseEx ex = connectStream as ICloseEx; try { if (ex != null) { ex.CloseEx(CloseExState.Abort); } else if (connectStream != null) { connectStream.Close(); } } catch { } }
protected virtual void Dispose(bool disposing, CloseExState closeState) { try { if ((Interlocked.Increment(ref this._Disposed) == 1) && disposing) { ICloseEx wrappedStream = base.WrappedStream as ICloseEx; if (wrappedStream != null) { wrappedStream.CloseEx(closeState); } else { base.WrappedStream.Close(); } if (this.m_CacheDestroy) { if (this.m_IsStrictCacheErrors) { this.m_Cache.Remove(this.m_Key); } else { this.m_Cache.TryRemove(this.m_Key); } } else if (this.m_IsStrictCacheErrors) { this.m_Cache.Update(this.m_Key, this.m_Expires, this.m_LastModified, this.m_LastSynchronized, this.m_MaxStale, this.m_EntryMetadata, this.m_SystemMetadata); } else { this.m_Cache.TryUpdate(this.m_Key, this.m_Expires, this.m_LastModified, this.m_LastSynchronized, this.m_MaxStale, this.m_EntryMetadata, this.m_SystemMetadata); } } } finally { base.Dispose(disposing); } }
protected virtual void Dispose(bool disposing, CloseExState closeState) { try { if (disposing) { try { if (!this.m_HeadEOF) { ICloseEx headStream = this.m_HeadStream as ICloseEx; if (headStream != null) { headStream.CloseEx(closeState); } else { this.m_HeadStream.Close(); } } } finally { ICloseEx wrappedStream = base.WrappedStream as ICloseEx; if (wrappedStream != null) { wrappedStream.CloseEx(closeState); } else { base.WrappedStream.Close(); } } } } finally { base.Dispose(disposing); } }
protected virtual void Dispose(bool disposing, CloseExState closeState) { try { if (disposing) { try { ICloseEx wrappedStream = base.WrappedStream as ICloseEx; if (wrappedStream != null) { wrappedStream.CloseEx(closeState); } else { base.WrappedStream.Close(); } } finally { if (!this.m_SeenReadEOF) { closeState |= CloseExState.Abort; } if (this.m_ShadowStream is ICloseEx) { ((ICloseEx)this.m_ShadowStream).CloseEx(closeState); } else { this.m_ShadowStream.Close(); } } } } finally { base.Dispose(disposing); } }
/*++ * * Close - Closes the Response after the use. * * This causes the read stream to be closed. * * --*/ public override void Close() { if (Logging.On) { Logging.Enter(Logging.Web, this, "Close", ""); } if (!m_disposed) { m_disposed = true; try { Stream stream = m_ConnectStream; ICloseEx icloseEx = stream as ICloseEx; if (icloseEx != null) { icloseEx.CloseEx(CloseExState.Normal /* | CloseExState.Silent */); } else if (stream != null) { stream.Close(); } } finally { if (this.IsWebSocketResponse) { ConnectStream connectStream = m_ConnectStream as ConnectStream; if (connectStream != null && connectStream.Connection != null) { connectStream.Connection.ServicePoint.CloseConnectionGroup(ConnectionGroupName); } } } } if (Logging.On) { Logging.Exit(Logging.Web, this, "Close", ""); } }
protected virtual void Dispose(bool disposing, CloseExState closeState) { // All below calls should already be idempotent try { if (disposing) { try { if (!m_HeadEOF) { ICloseEx icloseEx = m_HeadStream as ICloseEx; if (icloseEx != null) { icloseEx.CloseEx(closeState); } else { m_HeadStream.Close(); } } } finally { ICloseEx icloseEx = WrappedStream as ICloseEx; if (icloseEx != null) { icloseEx.CloseEx(closeState); } else { WrappedStream.Close(); } } } } finally { base.Dispose(disposing); } }
internal void Abort() { if (!this._CanTakeNewRequest) { Stream stream = this._ResponseStream; if (stream != null) { try { if (Logging.On) { Logging.PrintWarning(Logging.RequestCache, SR.GetString("net_log_cache_closing_cache_stream", new object[] { "CacheProtocol#" + this.GetHashCode().ToString(NumberFormatInfo.InvariantInfo), "Abort()", stream.GetType().FullName, this._Validator.CacheKey })); } ICloseEx ex = stream as ICloseEx; if (ex != null) { ex.CloseEx(CloseExState.Silent | CloseExState.Abort); } else { stream.Close(); } } catch (Exception exception) { if (NclUtilities.IsFatal(exception)) { throw; } if (Logging.On) { Logging.PrintError(Logging.RequestCache, SR.GetString("net_log_cache_exception_ignored", new object[] { "CacheProtocol#" + this.GetHashCode().ToString(NumberFormatInfo.InvariantInfo), "stream.Close()", exception.ToString() })); } } } this.Reset(); } }