Skip to content

Commit ea75e90

Browse files
authored
Merge pull request #22 from nblumhardt/dev
Add missing synchronization around disposal of owned file streams
2 parents d1fb6f3 + 2e5fdc0 commit ea75e90

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/Serilog.Sinks.File/Sinks/File/FileSink.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,13 @@ public void Emit(LogEvent logEvent)
9393
}
9494

9595
/// <inheritdoc />
96-
public void Dispose() => _output.Dispose();
96+
public void Dispose()
97+
{
98+
lock (_syncRoot)
99+
{
100+
_output.Dispose();
101+
}
102+
}
97103

98104
/// <inheritdoc />
99105
public void FlushToDisk()

src/Serilog.Sinks.File/Sinks/File/SharedFileSink.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,13 @@ public void Emit(LogEvent logEvent)
146146

147147

148148
/// <inheritdoc />
149-
public void Dispose() => _fileOutput.Dispose();
149+
public void Dispose()
150+
{
151+
lock (_syncRoot)
152+
{
153+
_fileOutput.Dispose();
154+
}
155+
}
150156

151157
/// <inheritdoc />
152158
public void FlushToDisk()

0 commit comments

Comments
 (0)