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
Race condition in dispose #125
Comments
Hi Matt. Thanks for the great and detailed bug report (and excited to see this component being used in your work!). I agree that the line you've found is incorrect WRT thread safety and will throw if the collection is modified by one of the connections being closed in another thread whilst the .ToArray() is being executed. Yes please for the PR to fix this. Thanks |
matt-richardson
added a commit
to matt-richardson/smtpserver
that referenced
this issue
Dec 3, 2020
rnwood
pushed a commit
that referenced
this issue
Dec 11, 2020
rnwood
pushed a commit
to rnwood/smtp4dev
that referenced
this issue
Apr 19, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
We're facing a (rare) race condition in
Rnwood.SmtpServer.SmtpServer.KillConnections
:This is pretty rare:
(first one is testing async, second is testing sync)
Let me know if you want to see the tests/code in question - I dont think it's too important here.
Looking into the code, i think this line is causing the error. Even though
activeConnections
is a synchronized list, it's not threadsafe for enumeration. Looking at the docs, it seems the code needs to lock on the SyncRoot property before enumeration:Would you be willing to accept a PR that changes this?
The text was updated successfully, but these errors were encountered: