cURL
Haxx ad
libcurl

Shopping cart software, Online file storage, Online photo storage, Hosted shopping cart, Contact management software, Email marketing software, Project management software, Issue tracking software, Online notepad, Web publishing software

curl's project page on SourceForge.net

Sponsors:
Haxx

cURL > Mailing List > Monthly Index > Single Mail

curl-library Archives

Re: What is the proper way to get libcurl to free it resources when used within a C++ Class?

From: Joost Huizinga <jhu_list_at_woodwing.com>
Date: Wed, 25 Nov 2009 14:33:39 +0100

> I'm not calling curl_global_init()/curl_global_cleanup() more than
> once. I'm calling them only once. Xerces is a 3rd party library and
> I have no access to the source or know how they are using curl in
> the their library. This is a large C++ application and I'm using
> curl in only one class. In my ctor, I call curl_global_init() first
> then make a call to curl_easy_init(). According to the curl
> documentation, if you call curl_global_init(), you should call
> curl_global_cleanup(). Likewise it says if you call
> curl_easy_init(), then you should call curl_easy_cleanup(), but when
> I do this the application crashes with a SIGSEGV, Segmentation fault.

You may want to have a close look at CurlNetAccessor in the Xerces
library. That class controls the initialization of libcurl within
xerces and contains a subtle warning:

//
// Global once-only init and cleanup of curl
//
// The init count used here is not thread protected; we assume
// that creation of the CurlNetAccessor will be serialized by
// the application. If the application is also using curl, then
// care must be taken that curl is initialized only once, by some
// other means, or by overloading these methods.
//

One thing you can try to do is adding a CurlNetAccessor member
variable to your class that takes care of the initialization of
libcurl in your app and xerces. In addition remove the calls to
curl_global_init and curl_global_cleanup from ctor and dtor.

- Joost

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

These mail archives are generated by hypermail.

donate! Page updated November 16, 2009.
web site info

File upload with ASP.NET