From 996d5f6c4e21d3d8688674f20e6f4318e3ace607 Mon Sep 17 00:00:00 2001 From: jsdelfino Date: Sat, 2 Jan 2010 22:13:15 +0000 Subject: 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 --- sca-cpp/trunk/modules/http/curl.hpp | 43 +++++++++++++------------------------ 1 file changed, 15 insertions(+), 28 deletions(-) (limited to 'sca-cpp/trunk/modules/http') 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()) { + 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 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; } /** -- cgit v1.2.3