From fbdd3ad2caa200ad91faed4af3daa637fbb95b72 Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Fri, 30 Oct 2015 10:36:26 -0700 Subject: [PATCH] rgw: get some errors from req_data When reading request status, we need to check with req_data first, since it might have failed before we even got the chance to set our own status. Signed-off-by: Yehuda Sadeh --- src/rgw/rgw_http_client.cc | 13 +++++++++++++ src/rgw/rgw_http_client.h | 2 ++ src/rgw/rgw_rest_client.cc | 9 +++++++++ src/rgw/rgw_rest_client.h | 2 +- src/rgw/rgw_rest_conn.h | 6 ++++++ 5 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/rgw/rgw_http_client.cc b/src/rgw/rgw_http_client.cc index d336848c4c86c..381d51b1f17e3 100644 --- a/src/rgw/rgw_http_client.cc +++ b/src/rgw/rgw_http_client.cc @@ -167,6 +167,10 @@ struct rgw_http_req_data : public RefCountedObject { return done.read() != 0; } + int get_retcode() { + Mutex::Locker l(lock); + return ret; + } }; string RGWHTTPClient::to_str() @@ -176,6 +180,15 @@ string RGWHTTPClient::to_str() return method_str + " " + url_str; } +int RGWHTTPClient::get_req_retcode() +{ + if (!req_data) { + return -EINVAL; + } + + return req_data->get_retcode(); +} + int RGWHTTPClient::init_request(const char *method, const char *url, rgw_http_req_data *_req_data) { assert(!req_data); diff --git a/src/rgw/rgw_http_client.h b/src/rgw/rgw_http_client.h index 070d04d721c88..b390911136b01 100644 --- a/src/rgw/rgw_http_client.h +++ b/src/rgw/rgw_http_client.h @@ -64,6 +64,8 @@ public: rgw_http_req_data *get_req_data() { return req_data; } string to_str(); + + int get_req_retcode(); }; class RGWCompletionManager; diff --git a/src/rgw/rgw_rest_client.cc b/src/rgw/rgw_rest_client.cc index 530daacc7a4ac..9f54deeece237 100644 --- a/src/rgw/rgw_rest_client.cc +++ b/src/rgw/rgw_rest_client.cc @@ -13,6 +13,15 @@ #define dout_subsys ceph_subsys_rgw +int RGWRESTSimpleRequest::get_status() +{ + int retcode = get_req_retcode(); + if (retcode < 0) { + return retcode; + } + return status; +} + int RGWRESTSimpleRequest::receive_header(void *ptr, size_t len) { char line[len + 1]; diff --git a/src/rgw/rgw_rest_client.h b/src/rgw/rgw_rest_client.h index 1ae1a31169084..fb308f2a104f8 100644 --- a/src/rgw/rgw_rest_client.h +++ b/src/rgw/rgw_rest_client.h @@ -61,7 +61,7 @@ public: map& get_out_headers() { return out_headers; } int get_http_status() { return http_status; } - int get_status() { return status; } + int get_status(); }; diff --git a/src/rgw/rgw_rest_conn.h b/src/rgw/rgw_rest_conn.h index c6de48abf0654..d2ecf230a7e8d 100644 --- a/src/rgw/rgw_rest_conn.h +++ b/src/rgw/rgw_rest_conn.h @@ -177,6 +177,12 @@ public: } int wait_bl(bufferlist *pbl) { + int ret = req.wait(); + put(); + if (ret < 0) { + return ret; + } + if (req.get_status() < 0) { return req.get_status(); } -- 2.39.5