-
-
Notifications
You must be signed in to change notification settings - Fork 373
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
MimeMessage.WriteTo is not thread-safe even in different instances of MimeMessage #138
Comments
Instead of
It makes more sense to use
This, however, does not fix the problem. |
This will fix it: var options = FormatOptions.Default.Clone ();
var msg = messages.Take(1).First();
msg.WriteTo(options, ms); |
Thanks. I tried passing FormatOptions.Default.Clone() to the WriteTo method and the problem is solved. I see that you have made some changes to the code base. I did not get this new code, but the issue is solved. Do you think there is a chance I will have any problems using the code base I currently have and just passing FormatOptions.Default.Clone() to the WriteTo method? |
Yes, you should be fine. |
Thanks |
Added an internal HeaderList.Suppress property to hold the state instead. This is a far better fix for issue #138
If we have multiple MimeMessage instances, say 1000 instance. And I try to call WriteTo in parallel for these messages I will get some corrupted messages.
Here is a sample code:
The corrupted messages have either missing or extra mime headers.
If I uncomment the lock statement, everything works fine.
Please note that in the example, each thread/task is working with a different instance of MimeMessage
The simple.eml file is a very simple email file with no attachments. I have tried different files, and the problem happened for all of them.
It seems to me that there might be some shared state for different instances of MimeMessage
The text was updated successfully, but these errors were encountered: