mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
remove mutex from mono startup
This commit is contained in:
parent
a90908f0f7
commit
9663252d10
@ -1,13 +1,13 @@
|
|||||||
<Properties>
|
<Properties>
|
||||||
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug|x86" />
|
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug|x86" />
|
||||||
<MonoDevelop.Ide.Workbench ActiveDocument="MediaBrowser.ServerApplication\ApplicationHost.cs">
|
<MonoDevelop.Ide.Workbench ActiveDocument="MediaBrowser.Server.Mono\Program.cs">
|
||||||
<Files>
|
<Files>
|
||||||
<File FileName="MediaBrowser.Server.Implementations\HttpServer\HttpServer.cs" Line="1" Column="1" />
|
<File FileName="MediaBrowser.Server.Implementations\HttpServer\HttpServer.cs" Line="1" Column="1" />
|
||||||
<File FileName="MediaBrowser.Server.Mono\FFMpeg\FFMpegDownloader.cs" Line="1" Column="1" />
|
<File FileName="MediaBrowser.Server.Mono\FFMpeg\FFMpegDownloader.cs" Line="1" Column="1" />
|
||||||
<File FileName="MediaBrowser.Server.Mono\Networking\NetworkManager.cs" Line="28" Column="9" />
|
<File FileName="MediaBrowser.Server.Mono\Networking\NetworkManager.cs" Line="1" Column="1" />
|
||||||
<File FileName="MediaBrowser.ServerApplication\ApplicationHost.cs" Line="525" Column="50" />
|
<File FileName="MediaBrowser.ServerApplication\ApplicationHost.cs" Line="525" Column="50" />
|
||||||
<File FileName="MediaBrowser.Server.Mono\Native\NativeApp.cs" Line="24" Column="4" />
|
<File FileName="MediaBrowser.Server.Mono\Native\NativeApp.cs" Line="1" Column="1" />
|
||||||
<File FileName="MediaBrowser.Server.Mono\Program.cs" Line="105" Column="17" />
|
<File FileName="MediaBrowser.Server.Mono\Program.cs" Line="250" Column="64" />
|
||||||
</Files>
|
</Files>
|
||||||
</MonoDevelop.Ide.Workbench>
|
</MonoDevelop.Ide.Workbench>
|
||||||
<MonoDevelop.Ide.DebuggingService.Breakpoints>
|
<MonoDevelop.Ide.DebuggingService.Breakpoints>
|
||||||
|
@ -44,13 +44,11 @@ namespace MediaBrowser.Server.Implementations.Session
|
|||||||
/// <value>The configuration manager.</value>
|
/// <value>The configuration manager.</value>
|
||||||
private readonly IServerConfigurationManager _configurationManager;
|
private readonly IServerConfigurationManager _configurationManager;
|
||||||
|
|
||||||
private object _sessionLock = new object();
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The _active connections
|
/// The _active connections
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly Dictionary<string, SessionInfo> _activeConnections =
|
private readonly ConcurrentDictionary<string, SessionInfo> _activeConnections =
|
||||||
new Dictionary<string, SessionInfo>(StringComparer.OrdinalIgnoreCase);
|
new ConcurrentDictionary<string, SessionInfo>(StringComparer.OrdinalIgnoreCase);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Occurs when [playback start].
|
/// Occurs when [playback start].
|
||||||
@ -86,7 +84,7 @@ namespace MediaBrowser.Server.Implementations.Session
|
|||||||
/// <value>All connections.</value>
|
/// <value>All connections.</value>
|
||||||
public IEnumerable<SessionInfo> Sessions
|
public IEnumerable<SessionInfo> Sessions
|
||||||
{
|
{
|
||||||
get { return _activeConnections.Values.ToList().OrderByDescending(c => c.LastActivityDate); }
|
get { return _activeConnections.Values.OrderByDescending(c => c.LastActivityDate).ToList(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -195,29 +193,19 @@ namespace MediaBrowser.Server.Implementations.Session
|
|||||||
{
|
{
|
||||||
var key = clientType + deviceId + appVersion;
|
var key = clientType + deviceId + appVersion;
|
||||||
|
|
||||||
lock (_sessionLock)
|
var connection = _activeConnections.GetOrAdd(key, keyName => new SessionInfo
|
||||||
{
|
|
||||||
SessionInfo connection;
|
|
||||||
|
|
||||||
if (!_activeConnections.TryGetValue(key, out connection))
|
|
||||||
{
|
|
||||||
connection = new SessionInfo
|
|
||||||
{
|
{
|
||||||
Client = clientType,
|
Client = clientType,
|
||||||
DeviceId = deviceId,
|
DeviceId = deviceId,
|
||||||
ApplicationVersion = appVersion,
|
ApplicationVersion = appVersion,
|
||||||
Id = Guid.NewGuid()
|
Id = Guid.NewGuid()
|
||||||
};
|
});
|
||||||
|
|
||||||
_activeConnections[key] = connection;
|
|
||||||
}
|
|
||||||
|
|
||||||
connection.DeviceName = deviceName;
|
connection.DeviceName = deviceName;
|
||||||
connection.User = user;
|
connection.User = user;
|
||||||
|
|
||||||
return connection;
|
return connection;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Used to report that playback has started for an item
|
/// Used to report that playback has started for an item
|
||||||
|
@ -21,8 +21,6 @@ namespace MediaBrowser.Server.Mono
|
|||||||
{
|
{
|
||||||
private static ApplicationHost _appHost;
|
private static ApplicationHost _appHost;
|
||||||
|
|
||||||
private static Mutex _singleInstanceMutex;
|
|
||||||
|
|
||||||
private static ILogger _logger;
|
private static ILogger _logger;
|
||||||
|
|
||||||
private static MainWindow _mainWindow;
|
private static MainWindow _mainWindow;
|
||||||
@ -45,18 +43,6 @@ namespace MediaBrowser.Server.Mono
|
|||||||
|
|
||||||
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
|
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
|
||||||
|
|
||||||
bool createdNew;
|
|
||||||
|
|
||||||
//_singleInstanceMutex = new Mutex(true, @"Local\" + runningPath, out createdNew);
|
|
||||||
createdNew = true;
|
|
||||||
|
|
||||||
if (!createdNew)
|
|
||||||
{
|
|
||||||
_singleInstanceMutex = null;
|
|
||||||
logger.Info("Shutting down because another instance of Media Browser Server is already running.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (PerformUpdateIfNeeded(appPaths, logger))
|
if (PerformUpdateIfNeeded(appPaths, logger))
|
||||||
{
|
{
|
||||||
logger.Info("Exiting to perform application update.");
|
logger.Info("Exiting to perform application update.");
|
||||||
@ -71,8 +57,6 @@ namespace MediaBrowser.Server.Mono
|
|||||||
{
|
{
|
||||||
logger.Info("Shutting down");
|
logger.Info("Shutting down");
|
||||||
|
|
||||||
ReleaseMutex(logger);
|
|
||||||
|
|
||||||
_appHost.Dispose();
|
_appHost.Dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -230,24 +214,6 @@ namespace MediaBrowser.Server.Mono
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Releases the mutex.
|
|
||||||
/// </summary>
|
|
||||||
internal static void ReleaseMutex(ILogger logger)
|
|
||||||
{
|
|
||||||
if (_singleInstanceMutex == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.Debug("Releasing mutex");
|
|
||||||
|
|
||||||
_singleInstanceMutex.ReleaseMutex();
|
|
||||||
_singleInstanceMutex.Close();
|
|
||||||
_singleInstanceMutex.Dispose();
|
|
||||||
_singleInstanceMutex = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Performs the update if needed.
|
/// Performs the update if needed.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -278,24 +244,11 @@ namespace MediaBrowser.Server.Mono
|
|||||||
|
|
||||||
public static void Restart()
|
public static void Restart()
|
||||||
{
|
{
|
||||||
// Second instance will start first, so release the mutex and dispose the http server ahead of time
|
// Second instance will start first, so dispose so that the http ports will be available to the new instance
|
||||||
ReleaseMutex (_logger);
|
|
||||||
|
|
||||||
_appHost.Dispose();
|
_appHost.Dispose();
|
||||||
|
|
||||||
if (trayIcon != null) {
|
// Right now this method will just shutdown, but not restart
|
||||||
trayIcon.Visible = false;
|
Shutdown ();
|
||||||
trayIcon.Dispose ();
|
|
||||||
trayIcon = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_mainWindow != null) {
|
|
||||||
_mainWindow.HideAll ();
|
|
||||||
_mainWindow.Dispose ();
|
|
||||||
_mainWindow = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
Application.Quit ();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user