Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ CleanCacheAndDisposeIfUnused()

bool System.Net.Http.HttpConnectionPool.CleanCacheAndDisposeIfUnused ( )
inline

Definition at line 1587 of file HttpConnectionPool.cs.

1588 {
1592 lock (SyncObj)
1593 {
1595 {
1596 _disposed = true;
1597 return true;
1598 }
1599 _usedSinceLastCleanup = false;
1600 long tickCount = Environment.TickCount64;
1602 if (_availableHttp2Connections != null)
1603 {
1606 }
1607 }
1608 toDispose2?.ForEach(delegate(HttpConnectionBase c)
1609 {
1610 c.Dispose();
1611 });
1612 return false;
1613 static bool IsUsableConnection(HttpConnectionBase connection, long nowTicks, TimeSpan pooledConnectionLifetime, TimeSpan pooledConnectionIdleTimeout)
1614 {
1616 {
1617 long idleTicks = connection.GetIdleTicks(nowTicks);
1618 if ((double)idleTicks > pooledConnectionIdleTimeout.TotalMilliseconds)
1619 {
1620 if (System.Net.NetEventSource.Log.IsEnabled())
1621 {
1622 connection.Trace($"Scavenging connection. Idle {TimeSpan.FromMilliseconds(idleTicks)} > {pooledConnectionIdleTimeout}.", "CleanCacheAndDisposeIfUnused");
1623 }
1624 return false;
1625 }
1626 }
1628 {
1629 long lifetimeTicks = connection.GetLifetimeTicks(nowTicks);
1630 if ((double)lifetimeTicks > pooledConnectionLifetime.TotalMilliseconds)
1631 {
1632 if (System.Net.NetEventSource.Log.IsEnabled())
1633 {
1634 connection.Trace($"Scavenging connection. Lifetime {TimeSpan.FromMilliseconds(lifetimeTicks)} > {pooledConnectionLifetime}.", "CleanCacheAndDisposeIfUnused");
1635 }
1636 return false;
1637 }
1638 }
1639 if (!connection.CheckUsabilityOnScavenge())
1640 {
1641 if (System.Net.NetEventSource.Log.IsEnabled())
1642 {
1643 connection.Trace("Scavenging connection. Unexpected data or EOF received.", "CleanCacheAndDisposeIfUnused");
1644 }
1645 return false;
1646 }
1647 return true;
1648 }
1650 {
1651 int i;
1653 {
1654 }
1655 int num2 = 0;
1656 if (i < list.Count)
1657 {
1658 if (toDispose == null)
1659 {
1661 }
1662 int j = i + 1;
1663 while (j < list.Count)
1664 {
1666 {
1667 toDispose.Add(list[j]);
1668 }
1669 if (j < list.Count)
1670 {
1671 list[i++] = list[j++];
1672 }
1673 }
1674 num2 = list.Count - i;
1675 list.RemoveRange(i, num2);
1676 }
1677 return num2;
1678 }
1679 }
void Add(TKey key, TValue value)
List< Http2Connection > _availableHttp2Connections
readonly List< HttpConnection > _availableHttp11Connections
readonly HttpConnectionPoolManager _poolManager
static readonly System.Net.NetEventSource Log
static readonly TimeSpan InfiniteTimeSpan
Definition Timeout.cs:5

References System.Net.Http.HttpConnectionPool._associatedHttp11ConnectionCount, System.Net.Http.HttpConnectionPool._associatedHttp2ConnectionCount, System.Net.Http.HttpConnectionPool._availableHttp11Connections, System.Net.Http.HttpConnectionPool._availableHttp2Connections, System.Net.Http.HttpConnectionPool._disposed, System.Net.Http.HttpConnectionSettings._pooledConnectionIdleTimeout, System.Net.Http.HttpConnectionSettings._pooledConnectionLifetime, System.Net.Http.HttpConnectionPool._poolManager, System.Net.Http.HttpConnectionPool._usedSinceLastCleanup, System.Collections.Generic.Dictionary< TKey, TValue >.Add(), System.Net.Http.HttpConnectionBase.CheckUsabilityOnScavenge(), System.Collections.Generic.Dictionary< TKey, TValue >.Count, System.Net.Http.HttpConnectionBase.Dispose(), System.Net.Http.HttpConnectionBase.GetIdleTicks(), System.Net.Http.HttpConnectionBase.GetLifetimeTicks(), System.Threading.Timeout.InfiniteTimeSpan, System.list, System.Net.NetEventSource.Log, System.Net.Http.HttpConnectionPoolManager.Settings, System.Net.Http.HttpConnectionPool.SyncObj, System.T, System.Environment.TickCount64, and System.Net.Http.HttpConnectionBase.Trace().