]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
Objecter: fix error handling for decoding stat
authorJosh Durgin <josh.durgin@inktank.com>
Sun, 12 May 2013 21:29:28 +0000 (14:29 -0700)
committerJosh Durgin <josh.durgin@inktank.com>
Mon, 13 May 2013 02:26:19 +0000 (19:26 -0700)
r is just a local variable, changing it has no effect.
Set the per-operation return value if provided when a decoding
error occurs.

Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
src/osdc/Objecter.cc
src/osdc/Objecter.h

index 178ea67dade0fe69605459a8c826e7e558116b9b..e9e121024a7eddf2f2133f8b77278c4b52ca27f8 100644 (file)
@@ -1433,6 +1433,8 @@ void Objecter::handle_osd_op_reply(MOSDOpReply *m)
                   << " len " << p->outdata.length() << dendl;
     if (*pb)
       **pb = p->outdata;
+    // set rval before running handlers so that handlers
+    // can change it if e.g. decoding fails
     if (*pr)
       **pr = p->rval;
     if (*ph) {
index d3e6a3de2def5234d47f3bdb7ab8246316d9f472..d041e0688b91c32efca9e5d28c62e3f29edede8e 100644 (file)
@@ -185,7 +185,9 @@ struct ObjectOperation {
     uint64_t *psize;
     utime_t *pmtime;
     time_t *ptime;
-    C_ObjectOperation_stat(uint64_t *ps, utime_t *pm, time_t *pt) : psize(ps), pmtime(pm), ptime(pt) {}
+    int *prval;
+    C_ObjectOperation_stat(uint64_t *ps, utime_t *pm, time_t *pt, int *prval)
+      : psize(ps), pmtime(pm), ptime(pt), prval(prval) {}
     void finish(int r) {
       if (r >= 0) {
        bufferlist::iterator p = bl.begin();
@@ -200,9 +202,9 @@ struct ObjectOperation {
            *pmtime = mtime;
          if (ptime)
            *ptime = mtime.sec();
-       }
-       catch (buffer::error& e) {
-         r = -EIO;
+       } catch (buffer::error& e) {
+         if (prval)
+           *prval = -EIO;
        }
       }
     }
@@ -210,7 +212,8 @@ struct ObjectOperation {
   void stat(uint64_t *psize, utime_t *pmtime, int *prval) {
     add_op(CEPH_OSD_OP_STAT);
     unsigned p = ops.size() - 1;
-    C_ObjectOperation_stat *h = new C_ObjectOperation_stat(psize, pmtime, NULL);
+    C_ObjectOperation_stat *h = new C_ObjectOperation_stat(psize, pmtime, NULL,
+                                                          prval);
     out_bl[p] = &h->bl;
     out_handler[p] = h;
     out_rval[p] = prval;
@@ -218,7 +221,8 @@ struct ObjectOperation {
   void stat(uint64_t *psize, time_t *ptime, int *prval) {
     add_op(CEPH_OSD_OP_STAT);
     unsigned p = ops.size() - 1;
-    C_ObjectOperation_stat *h = new C_ObjectOperation_stat(psize, NULL, ptime);
+    C_ObjectOperation_stat *h = new C_ObjectOperation_stat(psize, NULL, ptime,
+                                                          prval);
     out_bl[p] = &h->bl;
     out_handler[p] = h;
     out_rval[p] = prval;