wininet(3/3): Protect OpenSSL initialization with critical section

Juan Lang juan.lang at gmail.com
Tue Sep 29 04:55:13 CDT 2009


At issue here is that the global variable OpenSSL_ssl_handle is used
as a sentinel to check whether library initialization is done.  The
initialization process is fairly long, however, so it's relatively
easy for the thread that assigns OpenSSL_ssl_handle to be preempted
before initialization is complete.  Rather than make non-static copies
of every function pointer, and only assign them all if an interlocked
exchange succeeds (like I did for SSL_CTX), I assume that dynamically
loading the same library twice in the same process will get the same
address in each case, and thus that overwriting OpenSSL_ssl_handle,
and all of the associated function pointers, is safe as long as the
pointers are consistent.  There is still a small chance that two
threads will decide to load OpenSSL and the function pointers, but
this is okay due to the late assignment of the sentinel and the use of
the critical section:  at worst two threads will assign
OpenSSL_ssl_handle, but neither will assume the function pointers are
valid until at least one of them completes initialization.
--Juan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0003-Protect-OpenSSL-initialization-with-critical-section.patch
Type: text/x-patch
Size: 3628 bytes
Desc: not available
URL: <http://www.winehq.org/pipermail/wine-patches/attachments/20090929/db55eda2/attachment.bin>


More information about the wine-patches mailing list