cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Calling curl_global_init in multi-threaded code

From: Dan Fandrich <dan_at_coneharvesters.com>
Date: Mon, 2 Feb 2009 15:32:10 -0800

On Mon, Feb 02, 2009 at 03:05:46PM -0800, James Cheng wrote:
> From http://curl.haxx.se/libcurl/c/curl_global_init.html, I see
>
> "This function is not thread safe. You must not call it when any other thread
> in the program (i.e. a thread sharing the same memory) is running. This doesn't
> just mean no other thread that is using libcurl. Because curl_global_init()
> calls functions of other libraries that are similarly thread unsafe, it could
> conflict with any other thread that uses these other libraries. "
>
> I'm trying to understand why this is necessary. In my application (on linux 2.6
> kernel), my program starts up and spawns a thread. My only use of libcurl is
> within the 2nd thread. From the description, it sounds like I would need to put
> the curl_global_init in my main startup thread, before it spawns the 2nd
> thread?

Take a look at the thread at http://curl.haxx.se/mail/lib-2008-02/0116.html
It's possible to ignore this restriction in certain closed cases, but
you have to know exactly what you're doing.

>>> Dan

-- 
http://www.MoveAnnouncer.com              The web change of address service
          Let webmasters know that your web site has moved
Received on 2009-02-03