From: Jason Dillaman Date: Mon, 15 Feb 2016 15:49:17 +0000 (-0500) Subject: librados_test_stub: ensure AIO callback is also flushed X-Git-Tag: v10.1.0~377^2~4 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=8756e808f5df82cb2707e6b6aa0e4c348c2f48df;p=ceph-ci.git librados_test_stub: ensure AIO callback is also flushed 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 --- diff --git a/src/test/librados_test_stub/TestRadosClient.cc b/src/test/librados_test_stub/TestRadosClient.cc index c72aa28af8f..789d40b28f1 100644 --- a/src/test/librados_test_stub/TestRadosClient.cc +++ b/src/test/librados_test_stub/TestRadosClient.cc @@ -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); } }