]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw, cls_user: handle error cases related to response decoding
authorYehuda Sadeh <yehuda@inktank.com>
Fri, 24 Jan 2014 01:04:06 +0000 (17:04 -0800)
committerYehuda Sadeh <yehuda@inktank.com>
Fri, 24 Jan 2014 23:07:36 +0000 (15:07 -0800)
Certain operations weren't handling errors in decode, add some missing
logic.

Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
src/cls/user/cls_user_client.cc
src/cls/user/cls_user_client.h
src/rgw/rgw_rados.cc

index d2f4b366fd74cce5f89df42eb1083b6583437c2e..d86c5bfc3cedd4c49a6b762b4237f94cb21cc20f 100644 (file)
@@ -45,9 +45,10 @@ class ClsUserListCtx : public ObjectOperationCompletion {
   list<cls_user_bucket_entry> *entries;
   string *marker;
   bool *truncated;
+  int *pret;
 public:
-  ClsUserListCtx(list<cls_user_bucket_entry> *_entries, string *_marker, bool *_truncated) :
-                                      entries(_entries), marker(_marker), truncated(_truncated) {}
+  ClsUserListCtx(list<cls_user_bucket_entry> *_entries, string *_marker, bool *_truncated, int *_pret) :
+                                      entries(_entries), marker(_marker), truncated(_truncated), pret(_pret) {}
   void handle_completion(int r, bufferlist& outbl) {
     if (r >= 0) {
       cls_user_list_buckets_ret ret;
@@ -61,15 +62,18 @@ public:
         if (marker)
           *marker = ret.marker;
       } catch (buffer::error& err) {
-        // nothing we can do about it atm
+        r = -EIO;
       }
     }
+    if (pret) {
+      *pret = r;
+    }
   }
 };
 
 void cls_user_bucket_list(librados::ObjectReadOperation& op,
                        const string& in_marker, int max_entries, list<cls_user_bucket_entry>& entries,
-                       string *out_marker, bool *truncated)
+                       string *out_marker, bool *truncated, int *pret)
 {
   bufferlist inbl;
   cls_user_list_buckets_op call;
@@ -78,14 +82,15 @@ void cls_user_bucket_list(librados::ObjectReadOperation& op,
 
   ::encode(call, inbl);
 
-  op.exec("user", "list_buckets", inbl, new ClsUserListCtx(&entries, out_marker, truncated));
+  op.exec("user", "list_buckets", inbl, new ClsUserListCtx(&entries, out_marker, truncated, pret));
 }
 
 class ClsUserGetHeaderCtx : public ObjectOperationCompletion {
   cls_user_header *header;
   RGWGetUserHeader_CB *ret_ctx;
+  int *pret;
 public:
-  ClsUserGetHeaderCtx(cls_user_header *_h, RGWGetUserHeader_CB *_ctx) : header(_h), ret_ctx(_ctx) {}
+  ClsUserGetHeaderCtx(cls_user_header *_h, RGWGetUserHeader_CB *_ctx, int *_pret) : header(_h), ret_ctx(_ctx), pret(_pret) {}
   ~ClsUserGetHeaderCtx() {
     if (ret_ctx) {
       ret_ctx->put();
@@ -100,24 +105,27 @@ public:
         if (header)
          *header = ret.header;
       } catch (buffer::error& err) {
-        // nothing we can do about it atm
+        r = -EIO;
       }
       if (ret_ctx) {
         ret_ctx->handle_response(r, ret.header);
       }
     }
+    if (pret) {
+      *pret = r;
+    }
   }
 };
 
 void cls_user_get_header(librados::ObjectReadOperation& op,
-                       cls_user_header *header)
+                       cls_user_header *header, int *pret)
 {
   bufferlist inbl;
   cls_user_get_header_op call;
 
   ::encode(call, inbl);
 
-  op.exec("user", "get_header", inbl, new ClsUserGetHeaderCtx(header, NULL));
+  op.exec("user", "get_header", inbl, new ClsUserGetHeaderCtx(header, NULL, pret));
 }
 
 int cls_user_get_header_async(IoCtx& io_ctx, string& oid, RGWGetUserHeader_CB *ctx)
@@ -126,7 +134,7 @@ int cls_user_get_header_async(IoCtx& io_ctx, string& oid, RGWGetUserHeader_CB *c
   cls_user_get_header_op call;
   ::encode(call, in);
   ObjectReadOperation op;
-  op.exec("user", "get_header", in, new ClsUserGetHeaderCtx(NULL, ctx));
+  op.exec("user", "get_header", in, new ClsUserGetHeaderCtx(NULL, ctx, NULL)); /* no need to pass pret, as we'll call ctx->handle_response() with correct error */
   AioCompletion *c = librados::Rados::aio_create_completion(NULL, NULL, NULL);
   int r = io_ctx.aio_operate(oid, c, &op, NULL);
   c->release();
index 62e96294997cd67ba6d523ad984303d77de13eb8..dcfdab6f6c4f276c1b94d16981d271cf71e1f907 100644 (file)
@@ -25,8 +25,9 @@ void cls_user_remove_bucket(librados::ObjectWriteOperation& op,  const cls_user_
 void cls_user_bucket_list(librados::ObjectReadOperation& op,
                        const string& in_marker, int max_entries,
                        list<cls_user_bucket_entry>& entries,
-                       string *out_marker, bool *truncated);
-void cls_user_get_header(librados::ObjectReadOperation& op, cls_user_header *header);
+                       string *out_marker, bool *truncated,
+                       int *pret);
+void cls_user_get_header(librados::ObjectReadOperation& op, cls_user_header *header, int *pret);
 int cls_user_get_header_async(librados::IoCtx& io_ctx, string& oid, RGWGetUserHeader_CB *ctx);
 
 #endif
index 2dbcd52595d1e6e2bea24ca80bd82672a76ce282..af3afe51a92cc4766d1017a7a674c58159631ab2 100644 (file)
@@ -5675,11 +5675,14 @@ int RGWRados::cls_user_get_header(const string& user_id, cls_user_header *header
     return r;
 
   librados::ObjectReadOperation op;
-  ::cls_user_get_header(op, header);
+  int rc;
+  ::cls_user_get_header(op, header, &rc);
   bufferlist ibl;
   r = io_ctx.operate(oid, &op, &ibl);
   if (r < 0)
     return r;
+  if (rc < 0)
+    return rc;
 
   return 0;
 }
@@ -5776,11 +5779,15 @@ int RGWRados::cls_user_list_buckets(rgw_obj& obj,
     return r;
 
   librados::ObjectReadOperation op;
-  cls_user_bucket_list(op, in_marker, max_entries, entries, out_marker, truncated);
+  int rc;
+
+  cls_user_bucket_list(op, in_marker, max_entries, entries, out_marker, truncated, &rc);
   bufferlist ibl;
   r = io_ctx.operate(oid, &op, &ibl);
   if (r < 0)
     return r;
+  if (rc < 0)
+    return rc;
 
   return 0;
 }