mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-08 10:44:23 -04:00
Fixing race condition in GetSessionInfo (#14131)
This commit is contained in:
parent
9ab22e9f8b
commit
97f9d0c7e6
@ -508,13 +508,11 @@ namespace Emby.Server.Implementations.Session
|
|||||||
ArgumentException.ThrowIfNullOrEmpty(deviceId);
|
ArgumentException.ThrowIfNullOrEmpty(deviceId);
|
||||||
|
|
||||||
var key = GetSessionKey(appName, deviceId);
|
var key = GetSessionKey(appName, deviceId);
|
||||||
|
SessionInfo newSession = CreateSessionInfo(key, appName, appVersion, deviceId, deviceName, remoteEndPoint, user);
|
||||||
CheckDisposed();
|
SessionInfo sessionInfo = _activeConnections.GetOrAdd(key, newSession);
|
||||||
|
if (ReferenceEquals(newSession, sessionInfo))
|
||||||
if (!_activeConnections.TryGetValue(key, out var sessionInfo))
|
|
||||||
{
|
{
|
||||||
sessionInfo = CreateSession(key, appName, appVersion, deviceId, deviceName, remoteEndPoint, user);
|
OnSessionStarted(newSession);
|
||||||
_activeConnections[key] = sessionInfo;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sessionInfo.UserId = user?.Id ?? Guid.Empty;
|
sessionInfo.UserId = user?.Id ?? Guid.Empty;
|
||||||
@ -538,7 +536,7 @@ namespace Emby.Server.Implementations.Session
|
|||||||
return sessionInfo;
|
return sessionInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
private SessionInfo CreateSession(
|
private SessionInfo CreateSessionInfo(
|
||||||
string key,
|
string key,
|
||||||
string appName,
|
string appName,
|
||||||
string appVersion,
|
string appVersion,
|
||||||
@ -582,7 +580,6 @@ namespace Emby.Server.Implementations.Session
|
|||||||
sessionInfo.HasCustomDeviceName = true;
|
sessionInfo.HasCustomDeviceName = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
OnSessionStarted(sessionInfo);
|
|
||||||
return sessionInfo;
|
return sessionInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user