Re: [reSIProcate] OpenSSLInit is not successfully ensuring the thread-safety of OpenSSL
CRYPTO_thread_id is implemented as follows, so we do not need to
specify a custom implementation for windows:
unsigned long CRYPTO_thread_id(void)
{
unsigned long ret=0;
if (id_callback == NULL)
{
#ifdef OPENSSL_SYS_WIN16
ret=(unsigned long)GetCurrentTask();
#elif defined(OPENSSL_SYS_WIN32)
ret=(unsigned long)GetCurrentThreadId();
#elif defined(GETPID_IS_MEANINGLESS)
ret=1L;
#else
ret=(unsigned long)getpid();
#endif
}
else
ret=id_callback();
return(ret);
}
On Wed, Nov 5, 2008 at 11:51 PM, Byron Campen <bcampen@xxxxxxxxxxxx> wrote:
> Here's the offending code:
> *snip*
> #if !defined(WIN32) && defined(PTHREADS)
> CRYPTO_set_id_callback(OpenSSLInit::threadIdFunction);
> #endif
> *snip*
> There is no such preprocessor macro as "PTHREADS". The correct thing to be
> checking for here, AFAICT, is "_POSIX_THREADS". We should change this code
> to something like
> #if !defined(WIN32)
> #if defined(_POSIX_THREADS)
> CRYPTO_set_id_callback(OpenSSLInit::threadIdFunction);
> #else
> #error Can't set OpenSSL up to be threadsafe!
> #endif
> #endif
> This assumes CRYPTO_thread_id() is set to something sensible by default on
> Windows; is this true Scott/Derek?
> Also, this code would need to use _POSIX_THREADS
> *snip*
> unsigned long
> OpenSSLInit::threadIdFunction()
> {
> #if defined(WIN32)
> assert(0);
> #else
> #ifndef PTHREADS
> assert(0);
> #endif
> unsigned long ret;
> ret= (unsigned long)pthread_self();
> return ret;
> #endif
> return 0;
> }
> *snip*
> Best regards,
> Byron Campen
>
> _______________________________________________
> resiprocate-devel mailing list
> resiprocate-devel@xxxxxxxxxxxxxxx
> https://list.resiprocate.org/mailman/listinfo/resiprocate-devel
>