diff options
author | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2010-01-02 22:13:15 +0000 |
---|---|---|
committer | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2010-01-02 22:13:15 +0000 |
commit | 996d5f6c4e21d3d8688674f20e6f4318e3ace607 (patch) | |
tree | be6a3d80f2cab11cd39d0f55bd4bc55793a2e735 /sca-cpp/trunk/modules/http | |
parent | dda9255a5c9336cd3078f85f02e88120563ad304 (diff) |
Cleaned up lifecycle handling of objects that hold library and file resources. Fixed pool stack initialization concurrency issue. Re-enabled watch strings to help watch compound values in debugger.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@895305 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
-rw-r--r-- | sca-cpp/trunk/modules/http/curl.hpp | 43 |
1 files changed, 15 insertions, 28 deletions
diff --git a/sca-cpp/trunk/modules/http/curl.hpp b/sca-cpp/trunk/modules/http/curl.hpp index 3478a590fd..d836eaa2f0 100644 --- a/sca-cpp/trunk/modules/http/curl.hpp +++ b/sca-cpp/trunk/modules/http/curl.hpp @@ -43,50 +43,37 @@ namespace tuscany { namespace http { /** - * CURL library context, one per process. + * CURL library runtime, one per process. */ -class CURLContext { +class CURLRuntime { public: - CURLContext() { + CURLRuntime() { curl_global_init(CURL_GLOBAL_ALL); } - ~CURLContext() { - curl_global_cleanup(); - } -}; - -CURLContext curlContext; +} curlRuntime; /** * Represents a CURL session handle. */ class CURLSession { public: - CURLSession() : ch(new (gc_new<CURLHandle>()) CURLHandle()) { + CURLSession() : h(curl_easy_init()), owner(true) { } - ~CURLSession() { + CURLSession(const CURLSession& c) : h(c.h), owner(false) { } - CURLSession(const CURLSession& c) : ch(c.ch) { + ~CURLSession() { + if (!owner) + return; + if (h == NULL) + return; + curl_easy_cleanup(h); } private: - class CURLHandle { - public: - CURLHandle() : h(curl_easy_init()) { - } - ~CURLHandle() { - curl_easy_cleanup(h); - h = NULL; - } - private: - CURL* h; - - friend CURL* handle(const CURLSession& c); - }; - - const gc_ptr<CURLHandle> ch; + CURL* h; + bool owner; friend CURL* handle(const CURLSession& c); }; @@ -95,7 +82,7 @@ private: * Returns the CURL handle used by a CURL session. */ CURL* handle(const CURLSession& c) { - return c.ch->h; + return c.h; } /** |