From 8756e808f5df82cb2707e6b6aa0e4c348c2f48df Mon Sep 17 00:00:00 2001 From: Jason Dillaman Date: Mon, 15 Feb 2016 10:49:17 -0500 Subject: [PATCH] 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 --- src/test/librados_test_stub/TestRadosClient.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/test/librados_test_stub/TestRadosClient.cc b/src/test/librados_test_stub/TestRadosClient.cc index c72aa28af8f5f..789d40b28f159 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); } } -- 2.39.5