cURL / Mailing Lists / curl-library / Single Mail

curl-library

Calling curl_global_init in multi-threaded code

From: James Cheng <jcheng_at_tivo.com>
Date: Mon, 2 Feb 2009 15:05:46 -0800

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?

-James
Received on 2009-02-03