cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: curl_global_init

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Thu, 14 Feb 2008 22:04:05 +0100 (CET)

On Thu, 14 Feb 2008, Georg Lippitsch wrote:

> Because if it is true, it would make it impossible to use curl in libraries
> that are dynamically loaded by other programs (like plug-ins), because you
> can never be sure that no threads are running.

If you use libcurl in a plugin that is run in an invidiual thread and your
plugin calls curl_global_init() and there might be more than one plugin like
this running within the same program, then correct you cannot safely use this
approach.

But the problem is not really running it in multiple threads, the problem is
when you run the inits simultaneously in multiple threads so for your plugin
example you can make some mutex magic that prevents the race to happen.

-- 
  Commercial curl and libcurl Technical Support: http://haxx.se/curl.html
Received on 2008-02-14