Hello,

I'm trying to write an interface to OpenSSL using BIO pairs. For testing purposes, I'm doing communication locally in two seperate threads (one accessing a server context, the other a client context) so I figured I should worry about thread safety. I read in the OpenSSL documentation that one could find out if thread support was enabled using this:

#define OPENSSL_THREAD_DEFINES
#include <openssl/opensslconf.h>
#if defined(THREADS)
  // thread support enabled
#else
  // no thread support
#endif

If I stick to this it appears that I have no thread support here on my system (Win32), but I see no mention of that OPENSSL_THREAD_DEFINES macro in opensslconf.h, or anywhere else. Also, I see that OPENSSL_THREADS is defined in opensslconf.h so I'm basically wondering if this part of the documentation is out of date and if this OPENSSL_THREADS means that thread support is enabled. If so, are the callbacks defined in th-lock.c still valid ? I get a few warnings when I compile those with my project, but C is like alcohol and cigarettes - you never watch the warnings.


Next question:
I'll probably do all the locking manually since the threads themselves aren't defined at the C code level for my app (I'm not sure if thread support will work transparently with OpenSSL for user level threads). So I'm wondering if just locking all access to the C module in which OpenSSL routines are called should be sufficient or are there particular sequences of calls that should be made atomically (that OpenSSL thread support would usually deal with) ?

Thanks for reading and eventually for answering.


--
Alain Damiral,

Université Catholique de Louvain - student
alain.damiral'at'student.info.ucl.ac.be


Hello Alain,
I think by default OpenSSL is build with multithread support i.e. it links to multi-threaded version of CRT. But still you have provide the locks and two callbacks (for locking and unlocking & for getting thread id) then you are all set to use it in your multithreaded enviourment, I guess the VS linker spits out warnings if there is a CRT mismatch between the app & lib. And probably this THREADS flag is defined something like -D for the compiler in either the make file or some compilation script so that editing the .h/.c file is not needed. As to your second question, I am doing the IO on BIO atomically, dont know if its really required, :), But since my server's performance is quite resonable with it, so it's OK with me.
Regards,
Usman.

_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/

______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to