From 6da2232e9909f10176008ec00fd38d374a68f181 Mon Sep 17 00:00:00 2001 From: Abhishek Lekshmanan Date: Fri, 2 Mar 2018 10:41:51 +0100 Subject: [PATCH] rgw: rgw_admin also inits curl since we use http manager which in turn uses curl and uses curl multi interfaces. While curl is initialized at the first call of curl_easy_init() this method isn't guaranteed to be safe when multiple threads may call the function since curl_global_init isn't reentrant. Calling curl_global_init via rgw::curl::setup_curl which additionally sets up ssl interfaces etc. when openssl is used as curl's ssl backend. Similarly moving rgw target link to accomodate this change. Signed-off-by: Abhishek Lekshmanan (cherry picked from commit 112ba0b4dae5972b520aec39fe99275a6dfa899d) Conflicts: src/rgw/CMakeLists.txt beast submodule related changes which are not a part of this patchset src/rgw/rgw_admin.cc trivial whitespace conflicts # --- CMakeLists.txt | 1 + src/rgw/CMakeLists.txt | 8 ++++---- src/rgw/rgw_admin.cc | 3 +++ 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 56131a91b439..1adbc7309488 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -404,6 +404,7 @@ if (WITH_RADOSGW) find_package(OpenSSL) if (OPENSSL_FOUND) if (NOT NO_CURL_SSL_LINK) + message(STATUS "libcurl is linked with openssl: explicitly setting locks") set(WITH_CURL_OPENSSL ON) endif() # CURL_SSL_LINK execute_process( diff --git a/src/rgw/CMakeLists.txt b/src/rgw/CMakeLists.txt index 4d4f6a132a0c..b3aa4e38ada8 100644 --- a/src/rgw/CMakeLists.txt +++ b/src/rgw/CMakeLists.txt @@ -155,6 +155,10 @@ target_link_libraries(rgw_a librados cls_lock_client cls_rgw_client cls_refcount ${EXPAT_LIBRARIES} ${OPENLDAP_LIBRARIES} ${CRYPTO_LIBS}) +if (WITH_CURL_OPENSSL) + target_link_libraries(rgw_a ${OPENSSL_LIBRARIES}) +endif (WITH_CURL_OPENSSL) + set(radosgw_srcs rgw_loadgen_process.cc rgw_civetweb.cc @@ -189,10 +193,6 @@ add_dependencies(radosgw cls_rgw cls_lock cls_refcount cls_version cls_replica_log cls_user) install(TARGETS radosgw DESTINATION bin) -if (WITH_CURL_OPENSSL) - target_link_libraries(radosgw ${OPENSSL_LIBRARIES}) -endif (WITH_CURL_OPENSSL) - set(radosgw_admin_srcs rgw_admin.cc rgw_orphan.cc) diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index 141f3df32490..9ff804dcd915 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -44,6 +44,7 @@ #include "rgw_realm_watcher.h" #include "rgw_role.h" #include "rgw_reshard.h" +#include "rgw_http_client_curl.h" using namespace std; @@ -2952,6 +2953,7 @@ int main(int argc, const char **argv) rgw_user_init(store); rgw_bucket_init(store->meta_mgr); + rgw::curl::setup_curl(boost::none); StoreDestructor store_destructor(store); @@ -7109,5 +7111,6 @@ next: } } + rgw::curl::cleanup_curl(); return 0; } -- 2.47.3