mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-04-20 00:55:13 +01:00
fixed db disposals
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
using System.IO;
|
||||
using Funq;
|
||||
using MediaBrowser.Common;
|
||||
using MediaBrowser.Common.Extensions;
|
||||
@@ -17,6 +16,7 @@ using ServiceStack.WebHost.Endpoints.Support;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.WebSockets;
|
||||
@@ -498,6 +498,15 @@ namespace MediaBrowser.Server.Implementations.HttpServer
|
||||
_logger.Info("Calling ServiceStack AppHost.Init");
|
||||
Init();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Releases the specified instance.
|
||||
/// </summary>
|
||||
/// <param name="instance">The instance.</param>
|
||||
public override void Release(object instance)
|
||||
{
|
||||
// Leave this empty so SS doesn't try to dispose our objects
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -160,27 +160,30 @@ namespace MediaBrowser.Server.Implementations.Sqlite
|
||||
{
|
||||
try
|
||||
{
|
||||
if (connection != null)
|
||||
lock (this)
|
||||
{
|
||||
if (EnableDelayedCommands)
|
||||
if (connection != null)
|
||||
{
|
||||
FlushOnDispose();
|
||||
}
|
||||
|
||||
if (connection.IsOpen())
|
||||
{
|
||||
connection.Close();
|
||||
if (EnableDelayedCommands)
|
||||
{
|
||||
FlushOnDispose();
|
||||
}
|
||||
|
||||
if (connection.IsOpen())
|
||||
{
|
||||
connection.Close();
|
||||
}
|
||||
|
||||
connection.Dispose();
|
||||
connection = null;
|
||||
}
|
||||
|
||||
connection.Dispose();
|
||||
if (FlushTimer != null)
|
||||
{
|
||||
FlushTimer.Dispose();
|
||||
FlushTimer = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (FlushTimer != null)
|
||||
{
|
||||
FlushTimer.Dispose();
|
||||
FlushTimer = null;
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -195,13 +198,13 @@ namespace MediaBrowser.Server.Implementations.Sqlite
|
||||
private void FlushOnDispose()
|
||||
{
|
||||
// If we're not already flushing, do it now
|
||||
if (!IsFlushing)
|
||||
if (!_isFlushing)
|
||||
{
|
||||
Flush(null);
|
||||
}
|
||||
|
||||
// Don't dispose in the middle of a flush
|
||||
while (IsFlushing)
|
||||
while (_isFlushing)
|
||||
{
|
||||
Thread.Sleep(25);
|
||||
}
|
||||
@@ -225,7 +228,7 @@ namespace MediaBrowser.Server.Implementations.Sqlite
|
||||
/// <summary>
|
||||
/// The is flushing
|
||||
/// </summary>
|
||||
private bool IsFlushing;
|
||||
private bool _isFlushing;
|
||||
|
||||
/// <summary>
|
||||
/// Flushes the specified sender.
|
||||
@@ -241,12 +244,12 @@ namespace MediaBrowser.Server.Implementations.Sqlite
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsFlushing)
|
||||
if (_isFlushing)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
IsFlushing = true;
|
||||
_isFlushing = true;
|
||||
var numCommands = 0;
|
||||
|
||||
using (var tran = connection.BeginTransaction())
|
||||
@@ -278,7 +281,7 @@ namespace MediaBrowser.Server.Implementations.Sqlite
|
||||
Logger.Debug("SQL Delayed writer executed " + numCommands + " commands");
|
||||
|
||||
FlushTimer.Change(TimeSpan.FromMilliseconds(FlushInterval), TimeSpan.FromMilliseconds(-1));
|
||||
IsFlushing = false;
|
||||
_isFlushing = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user