From e037abd9d253f98d49af377bf56c431bb14043e6 Mon Sep 17 00:00:00 2001 From: Abhishek Lekshmanan Date: Tue, 27 Feb 2018 23:11:30 +0100 Subject: [PATCH] rgw: make frontend map optional for ssl init Since rgw admin also needs to init curl globally where we don't have a frontend map Signed-off-by: Abhishek Lekshmanan (cherry picked from commit 55dde3df50a9735b81c6b31f5683ebda1dabd5e2) --- src/rgw/rgw_http_client_curl.cc | 25 ++++++++++++++----------- src/rgw/rgw_http_client_curl.h | 3 ++- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/rgw/rgw_http_client_curl.cc b/src/rgw/rgw_http_client_curl.cc index 27240caf5b43a..fdb4c48c3a955 100644 --- a/src/rgw/rgw_http_client_curl.cc +++ b/src/rgw/rgw_http_client_curl.cc @@ -65,7 +65,6 @@ void init_ssl(){ namespace rgw { namespace curl { -std::once_flag curl_init_flag; static void check_curl() { @@ -80,15 +79,17 @@ void init_ssl() { ::openssl::init_ssl(); } -bool fe_inits_ssl(const fe_map_t& m, long& curl_global_flags){ - for (const auto& kv: m){ - if (kv.first == "civetweb" || kv.first == "beast"){ - std::string cert; - kv.second->get_val("ssl_certificate","", &cert); - if (!cert.empty()){ - /* TODO this flag is no op for curl > 7.57 */ - curl_global_flags &= ~CURL_GLOBAL_SSL; - return true; +bool fe_inits_ssl(boost::optional m, long& curl_global_flags){ + if (m) { + for (const auto& kv: *m){ + if (kv.first == "civetweb" || kv.first == "beast"){ + std::string cert; + kv.second->get_val("ssl_certificate","", &cert); + if (!cert.empty()){ + /* TODO this flag is no op for curl > 7.57 */ + curl_global_flags &= ~CURL_GLOBAL_SSL; + return true; + } } } } @@ -96,7 +97,9 @@ bool fe_inits_ssl(const fe_map_t& m, long& curl_global_flags){ } #endif // WITH_CURL_OPENSSL -void setup_curl(const fe_map_t& m) { +std::once_flag curl_init_flag; + +void setup_curl(boost::optional m) { check_curl(); long curl_global_flags = CURL_GLOBAL_ALL; diff --git a/src/rgw/rgw_http_client_curl.h b/src/rgw/rgw_http_client_curl.h index fe44dfcedb98c..aad61950e9ec6 100644 --- a/src/rgw/rgw_http_client_curl.h +++ b/src/rgw/rgw_http_client_curl.h @@ -15,13 +15,14 @@ #define RGW_HTTP_CLIENT_CURL_H #include +#include #include "rgw_frontend.h" namespace rgw { namespace curl { using fe_map_t = std::multimap ; -void setup_curl(const fe_map_t& m); +void setup_curl(boost::optional m); void cleanup_curl(); } } -- 2.39.5