Fix bug in configuration reload

This commit is contained in:
Carsten Larsen 2016-12-15 20:52:24 +01:00
parent 783cb383d0
commit dcb99e3684
3 changed files with 12 additions and 4 deletions

View File

@ -47,6 +47,7 @@ public override void Close()
writer = null;
}
Initialized = false;
Closed = true;
}
}
@ -65,12 +66,15 @@ private void Dispose(bool disposing)
if (disposedValue)
return;
if (disposing)
if (disposing && writer != null)
{
writer.Close();
writer.Dispose();
writer = null;
}
disposedValue = true;
Closed = true;
}
~FileLog()

View File

@ -39,6 +39,7 @@ protected TextLog(Severity treshold, string timeFormat)
protected readonly object Locker = new object();
private readonly string timeFormat;
protected bool Closed;
protected bool Initialized;
private bool suspended;
private TextWriter writer;
@ -51,7 +52,7 @@ public override void Initialize()
{
lock (Locker)
{
if (!Initialized && !suspended)
if (!Initialized && !suspended && !Closed)
{
writer = CreateWriter();
Initialized = true;
@ -87,6 +88,9 @@ public override void WriteLine(string text, Severity severity)
if (!Initialized)
Initialize();
if (!Initialized)
return;
lock (Locker)
{
if (Initialized && !suspended && cache.Count != 0)

View File

@ -67,14 +67,14 @@ private void Execute()
{
case InterProcess.Signal.Exit:
loop = false;
RaiseExitApplicationEvent();
log.SignalClosing();
RaiseExitApplicationEvent();
break;
case InterProcess.Signal.Reload:
Reload = true;
loop = false;
RaiseExitApplicationEvent();
log.SignalReloading();
RaiseExitApplicationEvent();
break;
case InterProcess.Signal.Refresh:
var thread = new Thread(() =>