]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: create global http manager
authorYehuda Sadeh <yehuda@redhat.com>
Mon, 28 Aug 2017 09:33:20 +0000 (02:33 -0700)
committerYehuda Sadeh <yehuda@redhat.com>
Tue, 10 Apr 2018 15:05:37 +0000 (08:05 -0700)
Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
src/rgw/rgw_admin.cc
src/rgw/rgw_http_client.cc
src/rgw/rgw_http_client.h
src/rgw/rgw_main.cc

index 108ef379823386d82af23c7afd7ba2186786f1a9..35e9cb0a14f40321ca96460afa2c35f5de55831a 100644 (file)
@@ -1089,6 +1089,7 @@ public:
   explicit StoreDestructor(RGWRados *_s) : store(_s) {}
   ~StoreDestructor() {
     RGWStoreManager::close_storage(store);
+    rgw_http_client_cleanup();
   }
 };
 
@@ -3108,6 +3109,7 @@ int main(int argc, const char **argv)
   rgw_bucket_init(store->meta_mgr);
   rgw_otp_init(store);
 
+  rgw_http_client_init(g_ceph_context);
 
   struct rgw_curl_setup {
     rgw_curl_setup() {
index d0f90a5617d215957ecfda127ece8aa593ca85ff..32ca8613329e97bad948858dd616d20c5701d992 100644 (file)
@@ -21,6 +21,8 @@
 #define dout_context g_ceph_context
 #define dout_subsys ceph_subsys_rgw
 
+RGWHTTPManager *rgw_http_manager;
+
 struct rgw_http_req_data : public RefCountedObject {
   CURL *easy_handle{nullptr};
   curl_slist *h{nullptr};
@@ -1240,4 +1242,42 @@ void *RGWHTTPManager::reqs_thread_entry()
   return 0;
 }
 
+void rgw_http_client_init(CephContext *cct)
+{
+  curl_global_init(CURL_GLOBAL_ALL);
+  rgw_http_manager = new RGWHTTPManager(cct);
+  rgw_http_manager->set_threaded();
+}
+
+void rgw_http_client_cleanup()
+{
+  rgw_http_manager->stop();
+  delete rgw_http_manager;
+  curl_global_cleanup();
+}
+
+
+int RGWHTTP::send(RGWHTTPClient *req) {
+  if (!req) {
+    return 0;
+  }
+  int r = rgw_http_manager->add_request(req);
+  if (r < 0) {
+    return r;
+  }
+
+  return 0;
+}
+
+int RGWHTTP::process(RGWHTTPClient *req) {
+  if (!req) {
+    return 0;
+  }
+  int r = send(req);
+  if (r < 0) {
+    return r;
+  }
+
+  return req->wait();
+}
 
index a8bbaa17b96513028f9cefc845a56a64547d203a..fbe5d3626c0d9e2d362b4ae15fa1807bd5152128 100644 (file)
@@ -14,6 +14,9 @@
 using param_pair_t = pair<string, string>;
 using param_vec_t = vector<param_pair_t>;
 
+void rgw_http_client_init(CephContext *cct);
+void rgw_http_client_cleanup();
+
 struct rgw_http_req_data;
 class RGWHTTPManager;
 
@@ -317,4 +320,10 @@ public:
   int complete_requests();
 };
 
+class RGWHTTP
+{
+public:
+  static int send(RGWHTTPClient *req);
+  static int process(RGWHTTPClient *req);
+};
 #endif
index ac8c6e3cd3c239f79690e08e76374dc23ec88683..1a050b5a1fda911db2e5dd7119ede791a1c17a13 100644 (file)
@@ -298,7 +298,8 @@ int main(int argc, const char **argv)
 
   rgw_init_resolver();
   rgw::curl::setup_curl(fe_map);
-
+  rgw_http_client_init(g_ceph_context);
+  
 #if defined(WITH_RADOSGW_FCGI_FRONTEND)
   FCGX_Init();
 #endif
@@ -572,6 +573,7 @@ int main(int argc, const char **argv)
   rgw::auth::s3::LDAPEngine::shutdown();
   rgw_tools_cleanup();
   rgw_shutdown_resolver();
+  rgw_http_client_cleanup();
   rgw::curl::cleanup_curl();
 
   rgw_perf_stop(g_ceph_context);