cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: curl_global_init function call

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Sun, 15 Nov 2015 18:48:50 +0100 (CET)

On Sun, 15 Nov 2015, Praveen Pvs wrote:

> Need your guidance on usage of curl_global_init function call?
>
> Do we need to call this function every time or only once at the starting of
> the application?

Once per lifetime of the application.

> Does it mean that once in whole application?

Yes

> What if i have different threads which make libcurl function calls?

Doesn't matter, it is a global init.

> Do i need to make curl_global_init function call in each of this thread?

Nope.

> We are making curl_global_init function call in each of these threads in
> addition to one at start of the call. Do we need to call curl_global_cleanup
> when we are existing from this thread.

You shouldn't call curl_global_init for each thread, but you should call
curl_global_cleanup once for each time you called curl_global_init.

> Will there be memory leak if we dont call curl_global_cleanup function
> before exiting the online thread?

Perhaps, I don't think we're willing to guarantee that it won't ever be one
even if I think you won't leak memory now since only the first call to
curl_global_init will actually do anything and the following ones are just
increasing a counter.

-- 
  / daniel.haxx.se
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2015-11-15