From: Yehuda Sadeh Date: Fri, 30 Oct 2015 17:36:26 +0000 (-0700) Subject: rgw: get some errors from req_data X-Git-Tag: v10.1.0~354^2~260 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=fbdd3ad2caa200ad91faed4af3daa637fbb95b72;p=ceph.git 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 --- diff --git a/src/rgw/rgw_http_client.cc b/src/rgw/rgw_http_client.cc index d336848c4c86..381d51b1f17e 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 070d04d721c8..b390911136b0 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 530daacc7a4a..9f54deeece23 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 1ae1a3116908..fb308f2a104f 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 c6de48abf065..d2ecf230a7e8 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(); }