/// <summary> /// Closes expired connections and sends ping via inactive connections. /// </summary> /// <param name="ignored">Ignored.</param> private void Internal_TimerCallback(object ignored) { Internal_TimerCallback_Parameters internal_TimerCallback_Parameters = new Internal_TimerCallback_Parameters(); internal_TimerCallback_Parameters.ExpiredConnections = new ArrayList(); internal_TimerCallback_Parameters.SendPingTo = new ArrayList(); internal_TimerCallback_Parameters.CloseListenerConnectionsAfter = GenuineUtility.ConvertToMilliseconds(this.ITransportContext.IParameterProvider[GenuineParameter.ClosePersistentConnectionAfterInactivity]); internal_TimerCallback_Parameters.Now = GenuineUtility.TickCount; // go through the pool and close all expired connections this._persistent.InspectAllConnections(this._internal_TimerCallback_InspectPersistentConnections, internal_TimerCallback_Parameters); // send ping to expired foreach (HttpServerConnection httpServerConnection in internal_TimerCallback_Parameters.SendPingTo) this.Pool_SendThroughListener(httpServerConnection, HttpPacketType.ListenerTimedOut); // close expired connections foreach (HttpServerConnection httpServerConnection in internal_TimerCallback_Parameters.ExpiredConnections) { // just remove it silently this._persistent.Remove(httpServerConnection.Remote.Uri, httpServerConnection.ConnectionName); if (httpServerConnection.Listener != null) this.Pool_SendThroughListener(httpServerConnection, HttpPacketType.ClosedManually); } }
/// <summary> /// Closes expired connections and sends ping via inactive connections. /// </summary> /// <param name="ignored">Ignored.</param> private void Internal_TimerCallback(object ignored) { int now = GenuineUtility.TickCount; int sendPingAfter = GenuineUtility.ConvertToMilliseconds(this.ITransportContext.IParameterProvider[GenuineParameter.PersistentConnectionSendPingAfterInactivity]); #if DEBUG if (GenuineUtility.IsDebuggingModeEnabled) return ; #endif ArrayList expiredConnections = new ArrayList(); ArrayList sendPingTo = new ArrayList(); // go through the pool and close all expired connections // persistent Internal_TimerCallback_Parameters internal_TimerCallback_Parameters = new Internal_TimerCallback_Parameters(); internal_TimerCallback_Parameters.Now = now; internal_TimerCallback_Parameters.SendPingAfter = sendPingAfter; internal_TimerCallback_Parameters.ExpiredConnections = expiredConnections; internal_TimerCallback_Parameters.SendPingTo = sendPingTo; this._persistent.InspectAllConnections(this._internal_TimerCallback_InspectPersistentConnections, internal_TimerCallback_Parameters); foreach (XHttpConnection nextXHttpConnection in expiredConnections) this.ConnectionFailed(GenuineExceptions.Get_Channel_ConnectionClosedAfterTimeout(), nextXHttpConnection, null); foreach (XHttpConnection nextXHttpConnection in sendPingTo) GenuineThreadPool.QueueUserWorkItem(new WaitCallback(this.SendPing), nextXHttpConnection, true); }