[openssl-users] Is CRYPTO_set_locking_callback still needed if mutexes in threads are already being used to prevent race conditions?
Avery A. Tarasov
Avery.A.Tarasov at SecurityEngineer.Pro
Sun Jan 18 23:14:24 UTC 2015
Hi, I am developing a Windows C++ application that uses OpenSSL.
The application has 2 threads created by CreateThread that perform SSL
functions such as connecting to a website over HTTPS and
sending/receiving data
I am already using a mutex to prevent race conditions, like this:
static HANDLE sslmutex=0; // global variable at top of file
*inside thread #1:*
while(1)
{
WaitForSingleObject(sslmutex,INFINITE);
DoSsl();
ReleaseMutex(sslmutex);
Sleep(1000);
}
*inside thread #2:*
while(1)
{
WaitForSingleObject(sslmutex,INFINITE);
DoSsl();
ReleaseMutex(sslmutex);
Sleep(1000);
}
All SSL related code is in the DoSsl function including
SSL_library_init(), sending/receiving data, and necessary clean up
operations.
Is it still necessary for me to use CRYPTO_set_locking_callback or is my
code already thread safe?
Any assistance greatly appreciated.
Best Regards,
-Avery
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mta.openssl.org/pipermail/openssl-users/attachments/20150118/2f09921e/attachment.html>
More information about the openssl-users
mailing list