Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed issue: throw IOException: The process cannot access the file 'xxxx\log\Non-Session-Log.messages.current.log' because it is being used by another process. #890

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion QuickFIXn/Logger/NonSessionLog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace QuickFix.Logger;
/// A logger that can be used when the calling logic cannot identify a session (which is rare).
/// Does not create a file until first write.
/// </summary>
public class NonSessionLog {
public class NonSessionLog : System.IDisposable {

private readonly ILogFactory _logFactory;
private ILog? _log;
Expand All @@ -21,5 +21,7 @@ internal void OnEvent(string s) {
}
_log.OnEvent(s);
}

public void Dispose() => _log?.Dispose();
}

2 changes: 2 additions & 0 deletions QuickFIXn/ThreadedSocketAcceptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,8 @@ public void Stop(bool force)
LogoutAllSessions(force);
DisposeSessions();
_sessions.Clear();
_nonSessionLog.Dispose();
VAllens marked this conversation as resolved.
Show resolved Hide resolved
_isStarted = false;
VAllens marked this conversation as resolved.
Show resolved Hide resolved

// FIXME StopSessionTimer();
// FIXME Session.UnregisterSessions(GetSessions());
Expand Down
2 changes: 1 addition & 1 deletion UnitTests/ThreadedSocketReactorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public void TestStartOnBusyPort()
var ex = Assert.Throws<SocketException>(delegate { testingObject.Run(); })!;

StringAssert.StartsWith("<event> Error starting listener:", stdOut.ToString());
StringAssert.StartsWith("Address already in use", ex.Message);
Assert.That(ex.SocketErrorCode, Is.EqualTo(SocketError.AddressAlreadyInUse));
}

[TearDown]
Expand Down