From bc4c31a439a2cd201d89538fd519feefeb2aeb34 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Fri, 31 May 2019 09:37:35 -0500 Subject: [PATCH] mon/PaxosService: add C_ReplyOp Generic helper context to reply to an op on (successful) finish. Signed-off-by: Sage Weil --- src/mon/PaxosService.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/mon/PaxosService.h b/src/mon/PaxosService.h index 36d39ad799b..bb59688594b 100644 --- a/src/mon/PaxosService.h +++ b/src/mon/PaxosService.h @@ -124,6 +124,20 @@ public: } }; + class C_ReplyOp : public C_MonOp { + Monitor *mon; + MonOpRequestRef op; + MessageRef reply; + public: + C_ReplyOp(PaxosService *s, MonOpRequestRef o, MessageRef r) : + C_MonOp(o), mon(s->mon), op(o), reply(r) { } + void _finish(int r) override { + if (r >= 0) { + mon->send_reply(op, reply.detach()); + } + } + }; + /** * @} */ -- 2.39.5