]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librados_test_stub: assert that no AIO ops are outstanding on destruction
authorJason Dillaman <dillaman@redhat.com>
Tue, 21 Jul 2015 17:32:44 +0000 (13:32 -0400)
committerJason Dillaman <dillaman@redhat.com>
Fri, 6 Nov 2015 01:42:42 +0000 (20:42 -0500)
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/test/librados_test_stub/TestIoCtxImpl.cc
src/test/librados_test_stub/TestIoCtxImpl.h

index ebb5d745232c31f16c536b33a36d3d9da8e077bf..4bde5c94200ae0c9d0c12fd0e6d6411837d1e044 100644 (file)
@@ -38,6 +38,7 @@ TestIoCtxImpl::TestIoCtxImpl(const TestIoCtxImpl& rhs)
 }
 
 TestIoCtxImpl::~TestIoCtxImpl() {
+  assert(m_pending_ops.read() == 0);
 }
 
 void TestObjectOperationImpl::get() {
@@ -104,6 +105,7 @@ int TestIoCtxImpl::aio_operate(const std::string& oid, TestObjectOperationImpl &
                                int flags) {
   // TODO flags for now
   ops.get();
+  m_pending_ops.inc();
   m_client->add_aio_operation(oid, true, boost::bind(
     &TestIoCtxImpl::execute_aio_operations, this, oid, &ops,
     reinterpret_cast<bufferlist*>(0),
@@ -117,6 +119,7 @@ int TestIoCtxImpl::aio_operate_read(const std::string& oid,
                                     bufferlist *pbl) {
   // TODO ignoring flags for now
   ops.get();
+  m_pending_ops.inc();
   m_client->add_aio_operation(oid, true, boost::bind(
     &TestIoCtxImpl::execute_aio_operations, this, oid, &ops, pbl, m_snapc), c);
   return 0;
@@ -155,6 +158,7 @@ int TestIoCtxImpl::operate(const std::string& oid, TestObjectOperationImpl &ops)
   AioCompletionImpl *comp = new AioCompletionImpl();
 
   ops.get();
+  m_pending_ops.inc();
   m_client->add_aio_operation(oid, false, boost::bind(
     &TestIoCtxImpl::execute_aio_operations, this, oid, &ops,
     reinterpret_cast<bufferlist*>(0), m_snapc), comp);
@@ -170,6 +174,7 @@ int TestIoCtxImpl::operate_read(const std::string& oid, TestObjectOperationImpl
   AioCompletionImpl *comp = new AioCompletionImpl();
 
   ops.get();
+  m_pending_ops.inc();
   m_client->add_aio_operation(oid, false, boost::bind(
     &TestIoCtxImpl::execute_aio_operations, this, oid, &ops, pbl,
     m_snapc), comp);
@@ -279,6 +284,7 @@ int TestIoCtxImpl::execute_aio_operations(const std::string& oid,
       break;
     }
   }
+  m_pending_ops.dec();
   ops->put();
   return ret;
 }
index 37094adcc0f6f96b56f030c04e2151f3cce037eb..c38e90edb7e56f98b61eef22c7a3fb98036bdeaf 100644 (file)
@@ -172,6 +172,7 @@ private:
   snap_t m_snap_seq;
   SnapContext m_snapc;
   atomic_t m_refcount;
+  atomic_t m_pending_ops;
 
   void handle_aio_notify_complete(AioCompletionImpl *aio_comp, int r);
 };