]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
buffer: make 0-length splice() a no-op
authorSage Weil <sage@inktank.com>
Tue, 28 Jan 2014 18:26:12 +0000 (10:26 -0800)
committerSage Weil <sage@inktank.com>
Tue, 28 Jan 2014 18:31:28 +0000 (10:31 -0800)
This was causing a problem in the Striper, but fixing it here will avoid
corner cases all over the tree.  Note that we have to bail out before
the end-of-buffer check to avoid hitting that check when the bufferlist is
also empty.

Signed-off-by: Sage Weil <sage@inktank.com>
Reviewed-by: Greg Farnum <greg@inktank.com>
(cherry picked from commit ff5abfbdae07ae8a56fa83ebaa92000896f793c2)

src/common/buffer.cc
src/test/bufferlist.cc

index 493070557159e1dbc9d37d2abd16c407911f20f9..e2ca1ba9493cfefb12c19b3b5ffad238ee6a0490 100644 (file)
@@ -1087,6 +1087,9 @@ void buffer::list::rebuild_page_aligned()
   // funky modifer
   void buffer::list::splice(unsigned off, unsigned len, list *claim_by /*, bufferlist& replace_with */)
   {    // fixme?
+    if (len == 0)
+      return;
+
     if (off >= length())
       throw end_of_buffer();
 
index 8b6ca269234ff59e7c2292b615aa5a88ee65ea3f..53c0702985f42724557a4b92c53ec11566c9a8bc 100644 (file)
@@ -1522,7 +1522,7 @@ TEST(BufferList, splice) {
     bl.push_back(ptr);
   }
   EXPECT_EQ((unsigned)4, bl.buffers().size());
-  EXPECT_THROW(bl.splice(0, 0), FailedAssertion);
+  bl.splice(0, 0);
 
   bufferlist other;
   other.append('X');