cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: multi-threaded application using libcurl, about synchronized access

From: Selçuk Cihan <selcukcihan_at_gmail.com>
Date: Thu, 4 Feb 2010 16:25:14 +0200

Thanks for the response, i just found out that i was using an easy
handle that was uninitialized (was garbage). That was the problem. I
am not using SSL, so the mutex guard is fine then.

On Thu, Feb 4, 2010 at 3:36 PM, Daniel Stenberg <daniel_at_haxx.se> wrote:
> On Wed, 3 Feb 2010, Selçuk Cihan wrote:
>
>> "The first basic rule is that you must never share a libcurl handle (be it
>> easy or multi or whatever) between multiple threads. Only use one handle in
>> one thread at a time."
>>
>> I would like to know if this basic rule applies to synchronized access?
>
> It's the rule for all libcurl calls basically.
>
>> Calls to curl api are guarded by mutexes, is this enough? In callback
>> functions i do not use mutexes, i just lock the mutex before calling
>> curl_multi_perform, hopefully callbacks are also protected by the mutex.
>
> Since the callbacks are then done within the mutex guards, that will be
> fine.
>
>> I implemented the above mutex guarded multi-threaded application, and i am
>> getting segfaults from libcurl calls randomly, that is why i would like to
>> know if i am doing the wrong thing by calling curl from different threads.
>
> Are you perhaps using SSL based URLs (HTTPS or FTPS) and if so do you use
> the SSL libary's mutex functionality?
>
> --
>
>  / daniel.haxx.se
> -------------------------------------------------------------------
> List admin: http://cool.haxx.se/list/listinfo/curl-library
> Etiquette:  http://curl.haxx.se/mail/etiquette.html
>
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2010-02-04