From: Josh Durgin Date: Sun, 12 May 2013 21:29:28 +0000 (-0700) Subject: Objecter: fix error handling for decoding stat X-Git-Tag: v0.63~38^2~5 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ed76824c472358bc7610c136e3db78f8544451c9;p=ceph.git Objecter: fix error handling for decoding stat 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 --- diff --git a/src/osdc/Objecter.cc b/src/osdc/Objecter.cc index 178ea67dade0..e9e121024a7e 100644 --- a/src/osdc/Objecter.cc +++ b/src/osdc/Objecter.cc @@ -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) { diff --git a/src/osdc/Objecter.h b/src/osdc/Objecter.h index d3e6a3de2def..d041e0688b91 100644 --- a/src/osdc/Objecter.h +++ b/src/osdc/Objecter.h @@ -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;