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

Exception when removing and then adding the same session to ThreadedSocketAcceptor #541

Open
ageorgallides opened this issue Aug 2, 2019 · 0 comments

Comments

@ageorgallides
Copy link

1. Overview

We are attempting to dynamically Add/Remove sessions to/from the ThreadedSocketAcceptor so that any Initiator applications can Connect/Disconnect respectively. When Adding a session that was previously removed, an exception is thrown; "System.IO.IOException: The process cannot access the file 'C:\store\FIX.4.4-Sender-Target.header' because it is being used by another process.". Note that the above does not always occur and it seems that there is some kind of race condition. In addition, the exception can also refer to the .seqnums file as well.

2. A simplistic example of steps for reproducing the problem

SessionID sessionID = new SessionID(Values.BeginString_FIX44, "SenderID", "TargetID");
ThreadedSocketAcceptor acceptor = new ThreadedSocketAcceptor(...);
acceptor.AddSession(sessionID);
acceptor.Start();
while(true) {
acceptor.RemoveSession(sessionID, true);
acceptor.AddSession(sessionID); // throws Exception
}

3. Delving into the details

When AddSession(SessionID) is called, the FileStoreFactory creates a FileStore which then calls its private method ConstructFromFileCache(). While attempting to open the headerFileName_ it throws the aforementioned exception.

To me, the exception throw is very strange because RemoveSession(sessionID, true) was called prior calling AddSession(sessionID). RemoveSession disposes the Session which in turn disposes the FileStore which in turn disposes its headerFile_.

Can you please advise whether the above problem is already known?

Should we take any additional step in-between the acceptor.RemoveSession and acceptor.AddSession to guarantee that such an exception is not thrown?

Kind regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant