]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
test/librados_test_stub: always create copy of buffers passed to operation 21074/head
authorMykola Golub <mgolub@suse.com>
Tue, 27 Mar 2018 18:27:50 +0000 (21:27 +0300)
committerMykola Golub <mgolub@suse.com>
Tue, 27 Mar 2018 18:27:50 +0000 (21:27 +0300)
Otherwise the buffers may be shared between object files if the same
bufferlist was passed to several operations (append and write_full were
affected).

Signed-off-by: Mykola Golub <mgolub@suse.com>
src/test/librados_test_stub/TestMemIoCtxImpl.cc

index cc99b1ee710cc7b002cbf4717395031aee224737..ca2d2cd3108f09c5b6b1a79a2754e854d6047f95 100644 (file)
@@ -69,7 +69,9 @@ int TestMemIoCtxImpl::append(const std::string& oid, const bufferlist &bl,
   }
 
   RWLock::WLocker l(file->lock);
-  file->data.append(bl);
+  auto off = file->data.length();
+  ensure_minimum_length(off + bl.length(), &file->data);
+  file->data.copy_in(off, bl.length(), bl);
   return 0;
 }
 
@@ -579,7 +581,8 @@ int TestMemIoCtxImpl::write_full(const std::string& oid, bufferlist& bl,
   }
 
   file->data.clear();
-  file->data.append(bl);
+  ensure_minimum_length(bl.length(), &file->data);
+  file->data.copy_in(0, bl.length(), bl);
   return 0;
 }