Thanks for explanation. So the proper solution is to fix all the code using libcurl to call curl_global_init() at first, starting with the curl tool. Worth to write a patch?
Kamil On Saturday 07 of March 2009 22:33:53 Daniel Stenberg wrote: > On Sat, 7 Mar 2009, Kamil Dudka wrote: > > The value of 'initialized' is dependent on the order of call > > curl_global_init/curl_easy_init from the application. The information > > about this order is lost. > > The order is not important. By the API docs you SHOULD call > curl_global_init() first and curl_global_cleanup last. If you don't, > libcurl does its best to survive anyway and in my view it does that fairly > well. > > If you then choose not to adhere to the API, you risk a "leak" like this > yes. > > > Well, it works fine if you call curl_global_init and then curl_easy_init. > > But look at src/main.c - this is not the case. > > A) that is not libcurl code. > > B) I consider that a bug in the curl tool's code and we should fix it there > > > Then it never becomes zero and there is no cleanup. That's not what we > > need, is it? > > It's tough to depend on the counter that is counted up and down from within > the curl_easy_init() and curl_easy_cleanup() since they may be called > multi-threaded and the counter may thus not reach zero anyhow.
