From bd3079f5b4b3839ad4fbeceac72f3b4d5f2c84fe Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Fri, 8 Jun 2018 15:32:47 -0700 Subject: [PATCH] Fix buffers_adapter max_size --- CHANGELOG.md | 1 + include/boost/beast/core/impl/buffers_adapter.ipp | 3 --- test/beast/core/buffers_adapter.cpp | 5 ++--- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5c746f64..c1714761 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ Version 173: * Remove Autobahn testsuite doc note * Fix buffers_adapter iterator value type +* Fix buffers_adapter max_size -------------------------------------------------------------------------------- diff --git a/include/boost/beast/core/impl/buffers_adapter.ipp b/include/boost/beast/core/impl/buffers_adapter.ipp index d7f479ca..04483afe 100644 --- a/include/boost/beast/core/impl/buffers_adapter.ipp +++ b/include/boost/beast/core/impl/buffers_adapter.ipp @@ -447,20 +447,17 @@ buffers_adapter::commit(std::size_t n) { out_pos_ += n; in_size_ += n; - max_size_ -= n; return; } ++out_; n -= avail; out_pos_ = 0; in_size_ += avail; - max_size_ -= avail; } n = (std::min)(n, out_end_ - out_pos_); out_pos_ += n; in_size_ += n; - max_size_ -= n; if(out_pos_ == buffer_size(*out_)) { ++out_; diff --git a/test/beast/core/buffers_adapter.cpp b/test/beast/core/buffers_adapter.cpp index 3ce922dd..49f8091e 100644 --- a/test/beast/core/buffers_adapter.cpp +++ b/test/beast/core/buffers_adapter.cpp @@ -68,7 +68,7 @@ public: ba.commit(buffer_copy(d, buffer(s.data(), x))); } BEAST_EXPECT(ba.size() == x); - BEAST_EXPECT(ba.max_size() == sizeof(buf) - x); + BEAST_EXPECT(ba.max_size() == sizeof(buf)); BEAST_EXPECT(buffer_size(ba.data()) == ba.size()); { auto d = ba.prepare(x); @@ -89,7 +89,7 @@ public: } ba.commit(1); BEAST_EXPECT(ba.size() == x + y); - BEAST_EXPECT(ba.max_size() == sizeof(buf) - (x + y)); + BEAST_EXPECT(ba.max_size() == sizeof(buf)); BEAST_EXPECT(buffer_size(ba.data()) == ba.size()); { auto d = ba.prepare(x); @@ -109,7 +109,6 @@ public: } ba.commit(2); BEAST_EXPECT(ba.size() == x + y + z); - BEAST_EXPECT(ba.max_size() == 0); BEAST_EXPECT(buffer_size(ba.data()) == ba.size()); BEAST_EXPECT(buffers_to_string(ba.data()) == s); ba.consume(t);