mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-03-26 20:16:33 +00:00
reduce use of timers throughout the system
Conflicts: MediaBrowser.Common.Implementations/Networking/BaseNetworkManager.cs
This commit is contained in:
@@ -20,6 +20,14 @@ namespace MediaBrowser.Common.Implementations.Networking
|
||||
Logger = logger;
|
||||
}
|
||||
|
||||
private void ClearCacheTimerCallback(object state)
|
||||
{
|
||||
lock (_localIpAddressSyncLock)
|
||||
{
|
||||
_localIpAddresses = null;
|
||||
}
|
||||
}
|
||||
|
||||
private volatile List<IPAddress> _localIpAddresses;
|
||||
private readonly object _localIpAddressSyncLock = new object();
|
||||
|
||||
@@ -29,14 +37,13 @@ namespace MediaBrowser.Common.Implementations.Networking
|
||||
/// <returns>IPAddress.</returns>
|
||||
public IEnumerable<IPAddress> GetLocalIpAddresses()
|
||||
{
|
||||
const int cacheMinutes = 3;
|
||||
var forceRefresh = (DateTime.UtcNow - _lastRefresh).TotalMinutes >= cacheMinutes;
|
||||
var forceRefresh = (DateTime.UtcNow - _lastRefresh).TotalMinutes >= 1;
|
||||
|
||||
if (_localIpAddresses == null || forceRefresh)
|
||||
{
|
||||
lock (_localIpAddressSyncLock)
|
||||
{
|
||||
forceRefresh = (DateTime.UtcNow - _lastRefresh).TotalMinutes >= cacheMinutes;
|
||||
forceRefresh = (DateTime.UtcNow - _lastRefresh).TotalMinutes >= 1;
|
||||
|
||||
if (_localIpAddresses == null || forceRefresh)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user