]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: ensure all asio completions are complete at ImageCtx destruction
authorJason Dillaman <dillaman@redhat.com>
Fri, 10 Jul 2020 15:24:08 +0000 (11:24 -0400)
committerJason Dillaman <dillaman@redhat.com>
Thu, 16 Jul 2020 20:01:28 +0000 (16:01 -0400)
With multiple threads of execution possible, we need to ensure that
all completions have fired prior to the destruction of the AsioEngine.
We also need to ensure that the AsioEngine is destoyed outside the
context of its owned stands.

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/librbd/ImageCtx.cc
src/librbd/asio/ContextWQ.cc

index 2c238abbde73a5d396d51c152ce1321ad2789fdc..ddfa8efc7689455b76e58a0b091df16f3fe9553a 100644 (file)
@@ -172,6 +172,11 @@ librados::IoCtx duplicate_io_ctx(librados::IoCtx& io_ctx) {
     delete state;
 
     delete plugin_registry;
+
+    // destroy our AsioEngine via its shared io_context to ensure that we
+    // aren't executing within an AsioEngine-owned strand
+    auto& io_context = asio_engine->get_io_context();
+    boost::asio::post(io_context, [asio_engine=std::move(asio_engine)]() {});
   }
 
   void ImageCtx::init() {
index db4fadec69f6fb8b569b9a02d3156e086ce82367..2d12d5080fd1dec294e8aa0d946a88fc305ad8d1 100644 (file)
@@ -22,6 +22,7 @@ ContextWQ::ContextWQ(CephContext* cct, boost::asio::io_context& io_context)
 
 ContextWQ::~ContextWQ() {
   ldout(m_cct, 20) << dendl;
+  drain();
 }
 
 void ContextWQ::drain() {