]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librados_test_stub: ensure AIO callback is also flushed
authorJason Dillaman <dillaman@redhat.com>
Mon, 15 Feb 2016 15:49:17 +0000 (10:49 -0500)
committerJason Dillaman <dillaman@redhat.com>
Mon, 15 Feb 2016 17:33:15 +0000 (12:33 -0500)
There are sporadic librbd unit test failures due to the
mock being destroyed while an active librados_test_stub
AIO callback is completing.

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/test/librados_test_stub/TestRadosClient.cc

index c72aa28af8f5f7f7a0ec85813cf74ff5344ae212..789d40b28f15931e2c8994d9054a7639914836eb 100644 (file)
@@ -187,15 +187,15 @@ void TestRadosClient::add_aio_operation(const std::string& oid,
 struct WaitForFlush {
   int flushed() {
     if (count.dec() == 0) {
-      if (c != NULL) {
-       finish_aio_completion(c, 0);
-      }
+      aio_finisher->queue(new FunctionContext(boost::bind(
+        &finish_aio_completion, c, 0)));
       delete this;
     }
     return 0;
   }
 
   atomic_t count;
+  Finisher *aio_finisher;
   AioCompletionImpl *c;
 };
 
@@ -211,12 +211,13 @@ void TestRadosClient::flush_aio_operations(AioCompletionImpl *c) {
 
   WaitForFlush *wait_for_flush = new WaitForFlush();
   wait_for_flush->count.set(m_finishers.size());
+  wait_for_flush->aio_finisher = m_aio_finisher;
   wait_for_flush->c = c;
 
   for (size_t i = 0; i < m_finishers.size(); ++i) {
     AioFunctionContext *ctx = new AioFunctionContext(
       boost::bind(&WaitForFlush::flushed, wait_for_flush),
-      m_aio_finisher, NULL);
+      nullptr, nullptr);
     m_finishers[i]->queue(ctx);
   }
 }