Skip to content

Commit

Permalink
Merge pull request #6962 from liewegas/wip-buffer-lastp
Browse files Browse the repository at this point in the history
buffer: fix internal iterator invalidation on rebuild, get_contiguous

Reviewed-by: Samuel Just <sjust@redhat.com>
  • Loading branch information
liewegas committed Dec 31, 2015
2 parents b5a2a76 + b88561a commit d5b9767
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/common/buffer.cc
Expand Up @@ -1402,6 +1402,7 @@ static simple_spinlock_t buffer_debug_lock = SIMPLE_SPINLOCK_INITIALIZER;
if (nb.length())
_buffers.push_back(nb);
invalidate_crc();
last_p = begin();
}

void buffer::list::rebuild_aligned(unsigned align)
Expand Down Expand Up @@ -1449,6 +1450,7 @@ static simple_spinlock_t buffer_debug_lock = SIMPLE_SPINLOCK_INITIALIZER;
}
_buffers.insert(p, unaligned._buffers.front());
}
last_p = begin();
}

void buffer::list::rebuild_page_aligned()
Expand Down Expand Up @@ -1693,6 +1695,8 @@ static simple_spinlock_t buffer_debug_lock = SIMPLE_SPINLOCK_INITIALIZER;
return tmp.c_str() + off;
}

last_p = begin(); // we modified _buffers

return curbuf->c_str() + off;
}

Expand Down
11 changes: 11 additions & 0 deletions src/test/bufferlist.cc
Expand Up @@ -876,6 +876,17 @@ TEST(BufferListIterator, constructors) {
}
}

TEST(BufferListIterator, empty_create_append_copy) {
bufferlist bl, bl2, bl3, out;
bl2.append("bar");
bl.swap(bl2);
bl2.append("xxx");
bl.append(bl2);
bl.rebuild();
bl.copy(0, 6, out);
ASSERT_TRUE(out.contents_equal(bl));
}

TEST(BufferListIterator, operator_equal) {
bufferlist bl;
bl.append("ABC", 3);
Expand Down

0 comments on commit d5b9767

Please sign in to comment.