From: Jason Dillaman Date: Fri, 9 Sep 2016 14:42:50 +0000 (-0400) Subject: librbd: possible deadlock if cluster connection closed after image X-Git-Tag: v10.2.4~28^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=1ca4dc6d1bd6aebece500c6e91f6a9871af0e1f1;p=ceph.git librbd: possible deadlock if cluster connection closed after image Fixes: http://tracker.ceph.com/issues/17254 Signed-off-by: Jason Dillaman (cherry picked from commit 818c2f2abc972f689acb7d783c2a684bcc9e6e51) --- diff --git a/src/librbd/ImageWatcher.cc b/src/librbd/ImageWatcher.cc index 7aeb1c93489..c828163b8ad 100644 --- a/src/librbd/ImageWatcher.cc +++ b/src/librbd/ImageWatcher.cc @@ -54,13 +54,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); } };