From 818c2f2abc972f689acb7d783c2a684bcc9e6e51 Mon Sep 17 00:00:00 2001 From: Jason Dillaman Date: Fri, 9 Sep 2016 10:42:50 -0400 Subject: [PATCH] librbd: possible deadlock if cluster connection closed after image Fixes: http://tracker.ceph.com/issues/17254 Signed-off-by: Jason Dillaman --- src/librbd/ImageWatcher.cc | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/librbd/ImageWatcher.cc b/src/librbd/ImageWatcher.cc index 019130c32ad4..a534ae08a80b 100644 --- a/src/librbd/ImageWatcher.cc +++ b/src/librbd/ImageWatcher.cc @@ -55,13 +55,19 @@ struct C_UnwatchAndFlush : public Context { r = rados.aio_watch_flush(aio_comp); assert(r == 0); aio_comp->release(); - } else { - Context::complete(ret_val); + return; } + + // ensure our reference to the RadosClient is released prior + // to completing the callback to avoid racing an explicit + // librados shutdown + Context *ctx = on_finish; + delete this; + + ctx->complete(ret_val); } virtual void finish(int r) override { - on_finish->complete(r); } }; -- 2.47.3