From 8c5218f0f00c7a73dc9de851f1c1f1bbba4cdba7 Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Wed, 23 Jan 2019 15:41:44 -0800 Subject: [PATCH] rgw: http_client: propagate send_data_hint differently Fixes: http://tracker.ceph.com/issues/36092 send_data_hint is passed so that the lower http client layer to know in in cases where it's an http request that usually doesn't send data (e.g., GET) that the request will actually send data, and initialize the curl client correctly. In a case that was used by the elasticsearch mechanism it wasn't passed correctly. Now made it a data member in RGWHTTPClient, which also cleans the interface a bit. Signed-off-by: Yehuda Sadeh --- src/rgw/rgw_http_client.cc | 6 +++--- src/rgw/rgw_http_client.h | 10 +++++++--- src/rgw/rgw_rest_client.cc | 4 ++-- src/rgw/rgw_rest_client.h | 1 - 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/rgw/rgw_http_client.cc b/src/rgw/rgw_http_client.cc index c2764b816ed4b..50fe7915099fa 100644 --- a/src/rgw/rgw_http_client.cc +++ b/src/rgw/rgw_http_client.cc @@ -472,7 +472,7 @@ int RGWHTTPClient::get_req_retcode() /* * init request, will be used later with RGWHTTPManager */ -int RGWHTTPClient::init_request(rgw_http_req_data *_req_data, bool send_data_hint) +int RGWHTTPClient::init_request(rgw_http_req_data *_req_data) { ceph_assert(!req_data); _req_data->get(); @@ -930,11 +930,11 @@ void RGWHTTPManager::manage_pending_requests() } } -int RGWHTTPManager::add_request(RGWHTTPClient *client, bool send_data_hint) +int RGWHTTPManager::add_request(RGWHTTPClient *client) { rgw_http_req_data *req_data = new rgw_http_req_data; - int ret = client->init_request(req_data, send_data_hint); + int ret = client->init_request(req_data); if (ret < 0) { req_data->put(); req_data = NULL; diff --git a/src/rgw/rgw_http_client.h b/src/rgw/rgw_http_client.h index ec5aa20a5722d..04d8506e3903d 100644 --- a/src/rgw/rgw_http_client.h +++ b/src/rgw/rgw_http_client.h @@ -76,6 +76,7 @@ class RGWHTTPClient : public RGWIOProvider bufferlist::iterator send_iter; bool has_send_len; long http_status; + bool send_data_hint{false}; size_t receive_pause_skip{0}; /* how many bytes to skip next time receive_data is called due to being paused */ @@ -87,6 +88,7 @@ class RGWHTTPClient : public RGWIOProvider std::atomic stopped { 0 }; + protected: CephContext *cct; @@ -99,8 +101,7 @@ protected: RGWHTTPManager *get_manager(); - int init_request(rgw_http_req_data *req_data, - bool send_data_hint = false); + int init_request(rgw_http_req_data *req_data); virtual int receive_header(void *ptr, size_t len) { return 0; @@ -165,6 +166,9 @@ public: has_send_len = true; } + void set_send_data_hint(bool hint) { + send_data_hint = hint; + } long get_http_status() const { return http_status; @@ -347,7 +351,7 @@ public: int start(); void stop(); - int add_request(RGWHTTPClient *client, bool send_data_hint = false); + int add_request(RGWHTTPClient *client); int remove_request(RGWHTTPClient *client); int set_request_state(RGWHTTPClient *client, RGWHTTPRequestSetState state); }; diff --git a/src/rgw/rgw_rest_client.cc b/src/rgw/rgw_rest_client.cc index 5482a8f13d034..daf6a24e53daa 100644 --- a/src/rgw/rgw_rest_client.cc +++ b/src/rgw/rgw_rest_client.cc @@ -761,7 +761,7 @@ int RGWRESTStreamRWRequest::do_send_prepare(RGWAccessKey *key, maplength()); set_outbl(*send_data); - send_data_hint = true; + set_send_data_hint(true); } @@ -789,7 +789,7 @@ int RGWRESTStreamRWRequest::send(RGWHTTPManager *mgr) return RGWHTTP::send(this); } - int r = mgr->add_request(this, send_data_hint); + int r = mgr->add_request(this); if (r < 0) return r; diff --git a/src/rgw/rgw_rest_client.h b/src/rgw/rgw_rest_client.h index 4ce188857a6ac..8f9b2c16f5464 100644 --- a/src/rgw/rgw_rest_client.h +++ b/src/rgw/rgw_rest_client.h @@ -161,7 +161,6 @@ public: }; class RGWRESTStreamRWRequest : public RGWHTTPStreamRWRequest { - bool send_data_hint{false}; protected: HostStyle host_style; public: -- 2.39.5