News  [SoftwareSite

Latest News
Older News
RSS Feed
 
Complete Projects
Useful Classes
Top Downloads
Message Board
AllAPI.net
 
Send Comments
Software License
Mentalis.org Buttons
Donate
 
Forums -> Security Library Forum
 
Concurrency breakdown in GUI thread [v1.0.13.715]  
by Maxim
posted on 2006/02/23

The security library seems to be using two threads with WaitOne() and Set() to allow the worker thread to notify the (blocking) main thread when a response is recieved during synchronous communication. However, if the main thread happens to be the GUI thread, it is a special case in C# - when it is waiting, its stack can be re-used to process windows messages. It is thus possible to get a stack somewhat like this (growing from the bottom):

Seclib <- active
Network work
Event handler
<system code>
Seclib (waiting)
Network work
Event handler
<system code>
MainForm.run

Because the security library is being entered twice in the same thread, normal locking does not work. The result seems to be that the "outer" request is overwritten by the "inner" one(s) and thus the same resonse is received twice.

Apart from never ever calling upon the security library to do SSL things in the main thread, I can't see a good way to avoid this. Blocking the inner thread gives deadlock.

 

Copyright © 2002-2007, The Mentalis.org Team. All rights reserved.
This site is located at http://www.mentalis.org/
Send comments to the webmaster.