cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Threads & OpenSSL - Mutex what? Examples?

From: Toby Peterson <toby_at_apple.com>
Date: Fri, 27 Feb 2009 15:50:58 -0800

On Feb 27, 2009, at 1:57 PM, John D wrote:
> On Fri, Feb 27, 2009 at 8:55 AM, Daniel Stenberg <daniel_at_haxx.se>
> wrote:
>
>> On Thu, 26 Feb 2009, John D wrote:
>>
>>> As far as your advice though. I am a little unclear on some
>>> things if you don't mind.
>>>
>>> Particularly if thread_setup <ident?i=thread_setup>(void) is being
>>> called only once before all the treads are made or called from
>>> within each created thread. Same question goes for the destroy I
>>> guess.
>>>
>>> More so I am still unclear on void locking_function<ident?
>>> i=locking_function>in particular. I don't grasp if you call this
>>> directly and if so where? it is used to mutex a segment of my own
>>> code or automatic calls of the openssl lib.
>>
>> Then take a look at the somewhat more functional example as I
>> believe it answers those questions:
>>
>> http://curl.haxx.se/lxr/source/docs/examples/threaded-ssl.c
>>
>> The setup and destroy are done before any threads are started. The
>> locking function is what OpenSSL uses, it calls that function to
>> get a mutex functionality. I don't know the inner workings of
>> OpenSSL so I can't comment on any such.
>>
>> --
>>
>> / daniel.haxx.se
> Somewhat being the key word,
>
> test.cpp: In function âvoid init_locks()â:
> test.cpp:62: error: invalid conversion from âvoid (*)()â to âvoid (*)
> (int, int, const char*, int)â
> test.cpp:62: error: initializing argument 1 of âvoid
> CRYPTO_set_locking_callback(void (*)(int, int, const char*, int))â
>
> It doesn't compile. While I understand openssl being thread safe or
> not is not in anyway your fault,
> a lack of a thoroughly documented easy to follow way to make its use
> in libcurl so, most certainly is.
>
> Regards,
>
> John
>

It compiles fine as C, and it's a very simple error to fix if you need
it for C++

- Toby
Received on 2009-02-28