summaryrefslogtreecommitdiffstats
path: root/src/cls
diff options
context:
space:
mode:
authorYehuda Sadeh <yehuda@inktank.com>2014-01-24 02:04:06 +0100
committerYehuda Sadeh <yehuda@inktank.com>2014-01-25 00:07:36 +0100
commite5dc8d6583d5fe107a26fec9d3ca354c6ee6e588 (patch)
tree90ef881faf72937ffcaa4f0d7f874c66512eb1c4 /src/cls
parentrgw: implement restful set user quota request (diff)
downloadceph-e5dc8d6583d5fe107a26fec9d3ca354c6ee6e588.tar.xz
ceph-e5dc8d6583d5fe107a26fec9d3ca354c6ee6e588.zip
rgw, cls_user: handle error cases related to response decoding
Certain operations weren't handling errors in decode, add some missing logic. Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
Diffstat (limited to 'src/cls')
-rw-r--r--src/cls/user/cls_user_client.cc28
-rw-r--r--src/cls/user/cls_user_client.h5
2 files changed, 21 insertions, 12 deletions
diff --git a/src/cls/user/cls_user_client.cc b/src/cls/user/cls_user_client.cc
index d2f4b366fd7..d86c5bfc3ce 100644
--- a/src/cls/user/cls_user_client.cc
+++ b/src/cls/user/cls_user_client.cc
@@ -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();
diff --git a/src/cls/user/cls_user_client.h b/src/cls/user/cls_user_client.h
index 62e96294997..dcfdab6f6c4 100644
--- a/src/cls/user/cls_user_client.h
+++ b/src/cls/user/cls_user_client.h
@@ -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