From 1459af2edc58203c2da68c09ebff72bdc5bad0ff Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Wed, 30 Aug 2017 04:40:02 -0700 Subject: [PATCH] rgw: amend http client manager interface s/set_threaded/start s/is_threaded/is_started Signed-off-by: Yehuda Sadeh --- src/rgw/rgw_admin.cc | 4 ++-- src/rgw/rgw_data_sync.cc | 16 ++++++++-------- src/rgw/rgw_http_client.cc | 16 ++++++++-------- src/rgw/rgw_http_client.h | 4 ++-- src/rgw/rgw_period_pusher.cc | 4 ++-- src/rgw/rgw_rados.cc | 6 +++--- src/rgw/rgw_sync.cc | 8 ++++---- src/test/rgw/test_http_manager.cc | 2 +- 8 files changed, 30 insertions(+), 30 deletions(-) diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index 35e9cb0a14f..7b97e77a18a 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -6458,7 +6458,7 @@ next: RGWCoroutinesManager crs(store->ctx(), store->get_cr_registry()); RGWHTTPManager http(store->ctx(), crs.get_completion_mgr()); - int ret = http.set_threaded(); + int ret = http.start(); if (ret < 0) { cerr << "failed to initialize http client with " << cpp_strerror(ret) << std::endl; return -ret; @@ -6979,7 +6979,7 @@ next: if (opt_cmd == OPT_BILOG_AUTOTRIM) { RGWCoroutinesManager crs(store->ctx(), store->get_cr_registry()); RGWHTTPManager http(store->ctx(), crs.get_completion_mgr()); - int ret = http.set_threaded(); + int ret = http.start(); if (ret < 0) { cerr << "failed to initialize http client with " << cpp_strerror(ret) << std::endl; return -ret; diff --git a/src/rgw/rgw_data_sync.cc b/src/rgw/rgw_data_sync.cc index 21b5bdb01ad..9a97526a463 100644 --- a/src/rgw/rgw_data_sync.cc +++ b/src/rgw/rgw_data_sync.cc @@ -667,9 +667,9 @@ int RGWRemoteDataLog::init(const string& _source_zone, RGWRESTConn *_conn, RGWSy return 0; } - int ret = http_manager.set_threaded(); + int ret = http_manager.start(); if (ret < 0) { - ldout(store->ctx(), 0) << "failed in http_manager.set_threaded() ret=" << ret << dendl; + ldout(store->ctx(), 0) << "failed in http_manager.start() ret=" << ret << dendl; return ret; } @@ -694,9 +694,9 @@ int RGWRemoteDataLog::read_sync_status(rgw_data_sync_status *sync_status) // cannot run concurrently with run_sync(), so run in a separate manager RGWCoroutinesManager crs(store->ctx(), store->get_cr_registry()); RGWHTTPManager http_manager(store->ctx(), crs.get_completion_mgr()); - int ret = http_manager.set_threaded(); + int ret = http_manager.start(); if (ret < 0) { - ldout(store->ctx(), 0) << "failed in http_manager.set_threaded() ret=" << ret << dendl; + ldout(store->ctx(), 0) << "failed in http_manager.start() ret=" << ret << dendl; return ret; } RGWDataSyncEnv sync_env_local = sync_env; @@ -741,9 +741,9 @@ int RGWRemoteDataLog::init_sync_status(int num_shards) RGWCoroutinesManager crs(store->ctx(), store->get_cr_registry()); RGWHTTPManager http_manager(store->ctx(), crs.get_completion_mgr()); - int ret = http_manager.set_threaded(); + int ret = http_manager.start(); if (ret < 0) { - ldout(store->ctx(), 0) << "failed in http_manager.set_threaded() ret=" << ret << dendl; + ldout(store->ctx(), 0) << "failed in http_manager.start() ret=" << ret << dendl; return ret; } RGWDataSyncEnv sync_env_local = sync_env; @@ -3074,9 +3074,9 @@ int RGWBucketSyncStatusManager::init() return -EINVAL; } - int ret = http_manager.set_threaded(); + int ret = http_manager.start(); if (ret < 0) { - ldout(store->ctx(), 0) << "failed in http_manager.set_threaded() ret=" << ret << dendl; + ldout(store->ctx(), 0) << "failed in http_manager.start() ret=" << ret << dendl; return ret; } diff --git a/src/rgw/rgw_http_client.cc b/src/rgw/rgw_http_client.cc index 7535633d2ec..ccea463d2ec 100644 --- a/src/rgw/rgw_http_client.cc +++ b/src/rgw/rgw_http_client.cc @@ -766,7 +766,7 @@ void *RGWHTTPManager::ReqsThread::entry() * RGWHTTPManager has two modes of operation: threaded and non-threaded. */ RGWHTTPManager::RGWHTTPManager(CephContext *_cct, RGWCompletionManager *_cm) : cct(_cct), - completion_mgr(_cm), is_threaded(false), + completion_mgr(_cm), is_started(false), reqs_lock("RGWHTTPManager::reqs_lock"), num_reqs(0), max_threaded_req(0), reqs_thread(NULL) { @@ -942,7 +942,7 @@ int RGWHTTPManager::add_request(RGWHTTPClient *client, bool send_data_hint) register_request(req_data); - if (!is_threaded) { + if (!is_started) { ret = link_request(req_data); if (ret < 0) { req_data->put(); @@ -962,7 +962,7 @@ int RGWHTTPManager::remove_request(RGWHTTPClient *client) { rgw_http_req_data *req_data = client->get_req_data(); - if (!is_threaded) { + if (!is_started) { unlink_request(req_data); return 0; } @@ -982,7 +982,7 @@ int RGWHTTPManager::set_request_state(RGWHTTPClient *client, RGWHTTPRequestSetSt assert(req_data->lock.is_locked()); /* can only do that if threaded */ - if (!is_threaded) { + if (!is_started) { return -EINVAL; } @@ -1013,7 +1013,7 @@ int RGWHTTPManager::set_request_state(RGWHTTPClient *client, RGWHTTPRequestSetSt return 0; } -int RGWHTTPManager::set_threaded() +int RGWHTTPManager::start() { int r = pipe(thread_pipe); if (r < 0) { @@ -1040,7 +1040,7 @@ int RGWHTTPManager::set_threaded() thread_pipe[1], thread_pipe[0]); #endif - is_threaded = true; + is_started = true; reqs_thread = new ReqsThread(this); reqs_thread->create("http_manager"); return 0; @@ -1054,7 +1054,7 @@ void RGWHTTPManager::stop() is_stopped = true; - if (is_threaded) { + if (is_started) { going_down = true; signal_thread(); reqs_thread->join(); @@ -1157,7 +1157,7 @@ void rgw_http_client_init(CephContext *cct) { curl_global_init(CURL_GLOBAL_ALL); rgw_http_manager = new RGWHTTPManager(cct); - rgw_http_manager->set_threaded(); + rgw_http_manager->start(); } void rgw_http_client_cleanup() diff --git a/src/rgw/rgw_http_client.h b/src/rgw/rgw_http_client.h index ac230bfb2a6..dcc78d19904 100644 --- a/src/rgw/rgw_http_client.h +++ b/src/rgw/rgw_http_client.h @@ -263,7 +263,7 @@ class RGWHTTPManager { CephContext *cct; RGWCompletionManager *completion_mgr; void *multi_handle; - bool is_threaded; + bool is_started; std::atomic going_down { 0 }; std::atomic is_stopped { 0 }; @@ -307,7 +307,7 @@ public: RGWHTTPManager(CephContext *_cct, RGWCompletionManager *completion_mgr = NULL); ~RGWHTTPManager(); - int set_threaded(); + int start(); void stop(); int add_request(RGWHTTPClient *client, bool send_data_hint = false); diff --git a/src/rgw/rgw_period_pusher.cc b/src/rgw/rgw_period_pusher.cc index 7072c541368..ec676c23943 100644 --- a/src/rgw/rgw_period_pusher.cc +++ b/src/rgw/rgw_period_pusher.cc @@ -136,8 +136,8 @@ class RGWPeriodPusher::CRThread { http(cct, coroutines.get_completion_mgr()), push_all(new PushAllCR(cct, &http, std::move(period), std::move(conns))) { - http.set_threaded(); - // must spawn the CR thread after set_threaded + http.start(); + // must spawn the CR thread after start thread = std::thread([this] { coroutines.run(push_all.get()); }); } ~CRThread() diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index fa334ef906a..5ed3d0ec3cd 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -2978,7 +2978,7 @@ class RGWMetaNotifierManager : public RGWCoroutinesManager { public: RGWMetaNotifierManager(RGWRados *_store) : RGWCoroutinesManager(_store->ctx(), _store->get_cr_registry()), store(_store), http_manager(store->ctx(), completion_mgr) { - http_manager.set_threaded(); + http_manager.start(); } int notify_all(map& conn_map, set& shards) { @@ -3005,7 +3005,7 @@ class RGWDataNotifierManager : public RGWCoroutinesManager { public: RGWDataNotifierManager(RGWRados *_store) : RGWCoroutinesManager(_store->ctx(), _store->get_cr_registry()), store(_store), http_manager(store->ctx(), completion_mgr) { - http_manager.set_threaded(); + http_manager.start(); } int notify_all(map& conn_map, map >& shards) { @@ -3272,7 +3272,7 @@ public: {} int init() override { - return http.set_threaded(); + return http.start(); } int process() override { list stacks; diff --git a/src/rgw/rgw_sync.cc b/src/rgw/rgw_sync.cc index 3a1230ec144..f5bcfc98871 100644 --- a/src/rgw/rgw_sync.cc +++ b/src/rgw/rgw_sync.cc @@ -277,9 +277,9 @@ int RGWRemoteMetaLog::init() { conn = store->rest_master_conn; - int ret = http_manager.set_threaded(); + int ret = http_manager.start(); if (ret < 0) { - ldout(store->ctx(), 0) << "failed in http_manager.set_threaded() ret=" << ret << dendl; + ldout(store->ctx(), 0) << "failed in http_manager.start() ret=" << ret << dendl; return ret; } @@ -1999,9 +1999,9 @@ int RGWRemoteMetaLog::read_sync_status(rgw_meta_sync_status *sync_status) // cannot run concurrently with run_sync(), so run in a separate manager RGWCoroutinesManager crs(store->ctx(), store->get_cr_registry()); RGWHTTPManager http_manager(store->ctx(), crs.get_completion_mgr()); - int ret = http_manager.set_threaded(); + int ret = http_manager.start(); if (ret < 0) { - ldout(store->ctx(), 0) << "failed in http_manager.set_threaded() ret=" << ret << dendl; + ldout(store->ctx(), 0) << "failed in http_manager.start() ret=" << ret << dendl; return ret; } RGWMetaSyncEnv sync_env_local = sync_env; diff --git a/src/test/rgw/test_http_manager.cc b/src/test/rgw/test_http_manager.cc index 73626a7d9cf..3240dc8bfc8 100644 --- a/src/test/rgw/test_http_manager.cc +++ b/src/test/rgw/test_http_manager.cc @@ -23,7 +23,7 @@ TEST(HTTPManager, SignalThread) auto cct = g_ceph_context; RGWHTTPManager http(cct); - ASSERT_EQ(0, http.set_threaded()); + ASSERT_EQ(0, http.start()); // default pipe buffer size according to man pipe constexpr size_t max_pipe_buffer_size = 65536; -- 2.39.5