]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
common: avoid bl::get_current_ptr()-driven ref counting in denc.h.
authorRadoslaw Zarzynski <rzarzyns@redhat.com>
Mon, 17 Dec 2018 20:06:38 +0000 (21:06 +0100)
committerRadoslaw Zarzynski <rzarzyns@redhat.com>
Mon, 17 Dec 2018 20:07:51 +0000 (21:07 +0100)
Signed-off-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
src/common/buffer.cc
src/include/buffer.h
src/include/denc.h

index b1c533ed3100fb2b08891bd1e4e7bf98c523c887..8925d0076104035e2d5eba3a00c014ff48de73a4 100644 (file)
@@ -898,6 +898,15 @@ using namespace ceph;
     return ptr(*p, p_off, p->length() - p_off);
   }
 
+  template<bool is_const>
+  bool buffer::list::iterator_impl<is_const>::is_pointing_same_raw(
+    const ptr& other) const
+  {
+    if (p == ls->end())
+      throw end_of_buffer();
+    return p->get_raw() == other.get_raw();
+  }
+
   // copy data out.
   // note that these all _append_ to dest!
   template<bool is_const>
index 56c5e8154e2866e42d63a2582aa836b2172fe8ae..6038529b49e29511fd0b51f319fe4e914141af54 100644 (file)
@@ -728,6 +728,7 @@ namespace buffer CEPH_BUFFER_API {
       char operator*() const;
       iterator_impl& operator++();
       ptr get_current_ptr() const;
+      bool is_pointing_same_raw(const ptr& other) const;
 
       bl_t& get_bl() const { return *bl; }
 
index 1e0b38723cb02364e33c636fa3667c0cca8eb0fe..cc2b906bf02e7166408985edd7333a3de5d80f13 100644 (file)
@@ -1523,8 +1523,7 @@ inline std::enable_if_t<traits::supported && !traits::need_contiguous> decode(
   const auto& bl = p.get_bl();
   const auto remaining = bl.length() - p.get_off();
   // it is expensive to rebuild a contigous buffer and drop it, so avoid this.
-  if (p.get_current_ptr().get_raw() != bl.back().get_raw() &&
-      remaining > CEPH_PAGE_SIZE) {
+  if (!p.is_pointing_same_raw(bl.back()) && remaining > CEPH_PAGE_SIZE) {
     traits::decode(o, p);
   } else {
     // ensure we get a contigous buffer... until the end of the