AdrianSzymczak / jabber-net

Automatically exported from code.google.com/p/jabber-net
0 stars 0 forks source link

SASL Processors aren't "thread safe" #36

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a JabberClient on multiple threads.
2. Call Connect() on each.

What is the expected output? What do you see instead?

Each client should connect properly. Instead, some internal system errors 
are thrown (and then rethrown as SASLExceptions) such as "Safe handle has 
been closed". Upon further research, some SASLProcessor implementations 
(e.g. MD5Processor) are using private static .NET objects for their 
processing.

.NET's thread safety states that non-static methods are usually not thread-
safe. Using these objects as static objects violates that. The bug would 
be fixed by removing the 'static' decorator from those fields (the 
MD5CryptoServiceProvider and Regex). This would ensure that those objects 
aren't being used by multiple XmppStream objects.

Original issue reported on code.google.com by jcpst...@gmail.com on 5 Aug 2008 at 12:06

GoogleCodeExporter commented 9 years ago
Agree.  I didn't realize how ComputeHash was implemented.

The docs for Regex are misleading, making it look as if it would be 
thread-safe, but
the implementation is clearly not.  I've removed the compilation directive as 
well,
since that won't help any more.  CompileToAssembly() appears to be overkill for 
this
one regex.

Original comment by hil...@gmail.com on 5 Aug 2008 at 11:16