Skip to content

Commit

Permalink
rgw: rgw_admin also inits curl
Browse files Browse the repository at this point in the history
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 <abhishek@suse.com>
  • Loading branch information
theanalyst committed Mar 2, 2018
1 parent 55dde3d commit 112ba0b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,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(
Expand Down
8 changes: 4 additions & 4 deletions src/rgw/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@ if (WITH_RADOSGW_BEAST_FRONTEND)
target_link_libraries(rgw_a Boost::coroutine Boost::context)
endif()

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
Expand Down Expand Up @@ -191,10 +195,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)
Expand Down
4 changes: 3 additions & 1 deletion src/rgw/rgw_admin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
#include "rgw_realm_watcher.h"
#include "rgw_role.h"
#include "rgw_reshard.h"

#include "rgw_http_client_curl.h"

#define dout_context g_ceph_context
#define dout_subsys ceph_subsys_rgw
Expand Down Expand Up @@ -3014,6 +3014,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);

Expand Down Expand Up @@ -7246,5 +7247,6 @@ int main(int argc, const char **argv)
}
}

rgw::curl::cleanup_curl();
return 0;
}

0 comments on commit 112ba0b

Please sign in to comment.