]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: get some errors from req_data
authorYehuda Sadeh <yehuda@redhat.com>
Fri, 30 Oct 2015 17:36:26 +0000 (10:36 -0700)
committerYehuda Sadeh <yehuda@redhat.com>
Fri, 12 Feb 2016 00:13:26 +0000 (16:13 -0800)
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 <yehuda@redhat.com>
src/rgw/rgw_http_client.cc
src/rgw/rgw_http_client.h
src/rgw/rgw_rest_client.cc
src/rgw/rgw_rest_client.h
src/rgw/rgw_rest_conn.h

index d336848c4c86c7dc5ff1118235ce17e3be5104f8..381d51b1f17e3c406b415b142430b73ee7404159 100644 (file)
@@ -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);
index 070d04d721c88d1c46faa3d3ad0f3e06ccaa2ec7..b390911136b010a6e2a11469bee646e6e4502913 100644 (file)
@@ -64,6 +64,8 @@ public:
   rgw_http_req_data *get_req_data() { return req_data; }
 
   string to_str();
+
+  int get_req_retcode();
 };
 
 class RGWCompletionManager;
index 530daacc7a4acc807f676ba4830b242079dafbeb..9f54deeece237f35e0d44c695f3d56ff463876d6 100644 (file)
 
 #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];
index 1ae1a3116908428d4576bd5d6010a6b5842b9909..fb308f2a104f865624ac96f7204cdae19ce0f6cb 100644 (file)
@@ -61,7 +61,7 @@ public:
   map<string, string>& get_out_headers() { return out_headers; }
 
   int get_http_status() { return http_status; }
-  int get_status() { return status; }
+  int get_status();
 };
 
 
index c6de48abf0654cae21404c49bf91f8be3c1436ce..d2ecf230a7e8d3deabc34c8f2ab07df8f49565d7 100644 (file)
@@ -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();
     }