From: Sage Weil Date: Fri, 8 Feb 2013 07:13:17 +0000 (-0800) Subject: mon: assert valid context return values X-Git-Tag: v0.58~119 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=2bdf753d7d771062b03f47d79f6783c75d18ea38;p=ceph.git mon: assert valid context return values We recognized EAGAIN, ECANCELED, and success only. Signed-off-by: Sage Weil Reviewed-by: Joao Luis --- diff --git a/src/mon/MDSMonitor.h b/src/mon/MDSMonitor.h index d852785fa909..0e6471eb7b63 100644 --- a/src/mon/MDSMonitor.h +++ b/src/mon/MDSMonitor.h @@ -54,13 +54,10 @@ class MDSMonitor : public PaxosService { C_Updated(MDSMonitor *a, MMDSBeacon *c) : mm(a), m(c) {} void finish(int r) { - if (r == -ECANCELED) { - if (m) - m->put(); - return; - } if (r >= 0) mm->_updated(m); // success + else if (r == -ECANCELED) + m->put(); else mm->dispatch((PaxosServiceMessage*)m); // try again } diff --git a/src/mon/Monitor.h b/src/mon/Monitor.h index c7704bb16da3..e8baf8d864ce 100644 --- a/src/mon/Monitor.h +++ b/src/mon/Monitor.h @@ -460,10 +460,12 @@ public: void finish(int r) { if (r >= 0) mon->reply_command(m, rc, rs, rdata, version); - else if (r == -ECANCELED) { + else if (r == -ECANCELED) m->put(); - } else + else if (r == -EAGAIN) mon->_ms_dispatch(m); + else + assert(0 == "bad C_Command return value"); } }; @@ -474,10 +476,12 @@ public: public: C_RetryMessage(Monitor *m, Message *ms) : mon(m), msg(ms) {} void finish(int r) { - if (r == -ECANCELED) { - msg->put(); - } else + if (r == -EAGAIN || r >= 0) mon->_ms_dispatch(msg); + else if (r == -ECANCELED) + msg->put(); + else + assert(0 == "bad C_RetryMessage return value"); } }; diff --git a/src/mon/OSDMonitor.h b/src/mon/OSDMonitor.h index f53b6285abb2..f35992c43121 100644 --- a/src/mon/OSDMonitor.h +++ b/src/mon/OSDMonitor.h @@ -213,8 +213,10 @@ private: cmon->_booted(m, logit); else if (r == -ECANCELED) m->put(); - else + else if (r == -EAGAIN) cmon->dispatch((PaxosServiceMessage*)m); + else + assert(0 == "bad C_Booted return value"); } }; @@ -224,13 +226,14 @@ private: epoch_t e; C_ReplyMap(OSDMonitor *o, PaxosServiceMessage *mm, epoch_t ee) : osdmon(o), m(mm), e(ee) {} void finish(int r) { - if (r >= 0) { + if (r >= 0) osdmon->_reply_map(m, e); - } else if (r == -ECANCELED) { + else if (r == -ECANCELED) m->put(); - } else { + else if (r == -EAGAIN) osdmon->dispatch(m); - } + else + assert(0 == "bad C_ReplyMap return value"); } }; struct C_PoolOp : public Context { @@ -245,13 +248,14 @@ private: reply_data = *rd; } void finish(int r) { - if (r >= 0) { + if (r >= 0) osdmon->_pool_op_reply(m, replyCode, epoch, &reply_data); - } else if (r == -ECANCELED) { + else if (r == -ECANCELED) m->put(); - } else { + else if (r == -EAGAIN) osdmon->dispatch(m); - } + else + assert(0 == "bad C_PoolOp return value"); } }; diff --git a/src/mon/PGMonitor.h b/src/mon/PGMonitor.h index 5db1744111d5..0308e429d8d7 100644 --- a/src/mon/PGMonitor.h +++ b/src/mon/PGMonitor.h @@ -76,9 +76,11 @@ private: } else if (r == -ECANCELED) { req->put(); ack->put(); - } else { + } else if (r == -EAGAIN) { + pgmon->dispatch(req); ack->put(); - dispatch(req); + } else { + assert(0 == "bad C_Stats return value"); } } };