From 2bdf753d7d771062b03f47d79f6783c75d18ea38 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 7 Feb 2013 23:13:17 -0800 Subject: [PATCH] mon: assert valid context return values We recognized EAGAIN, ECANCELED, and success only. Signed-off-by: Sage Weil Reviewed-by: Joao Luis --- src/mon/MDSMonitor.h | 7 ++----- src/mon/Monitor.h | 14 +++++++++----- src/mon/OSDMonitor.h | 22 +++++++++++++--------- src/mon/PGMonitor.h | 6 ++++-- 4 files changed, 28 insertions(+), 21 deletions(-) diff --git a/src/mon/MDSMonitor.h b/src/mon/MDSMonitor.h index d852785fa90..0e6471eb7b6 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 c7704bb16da..e8baf8d864c 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 f53b6285abb..f35992c4312 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 5db1744111d..0308e429d8d 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"); } } }; -- 2.47.3