Fix buffers_adapter max_size

This commit is contained in:
Vinnie Falco
2018-06-08 15:32:47 -07:00
parent da9bb07d12
commit bd3079f5b4
3 changed files with 3 additions and 6 deletions

View File

@ -2,6 +2,7 @@ Version 173:
* Remove Autobahn testsuite doc note * Remove Autobahn testsuite doc note
* Fix buffers_adapter iterator value type * Fix buffers_adapter iterator value type
* Fix buffers_adapter max_size
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------

View File

@ -447,20 +447,17 @@ buffers_adapter<MutableBufferSequence>::commit(std::size_t n)
{ {
out_pos_ += n; out_pos_ += n;
in_size_ += n; in_size_ += n;
max_size_ -= n;
return; return;
} }
++out_; ++out_;
n -= avail; n -= avail;
out_pos_ = 0; out_pos_ = 0;
in_size_ += avail; in_size_ += avail;
max_size_ -= avail;
} }
n = (std::min)(n, out_end_ - out_pos_); n = (std::min)(n, out_end_ - out_pos_);
out_pos_ += n; out_pos_ += n;
in_size_ += n; in_size_ += n;
max_size_ -= n;
if(out_pos_ == buffer_size(*out_)) if(out_pos_ == buffer_size(*out_))
{ {
++out_; ++out_;

View File

@ -68,7 +68,7 @@ public:
ba.commit(buffer_copy(d, buffer(s.data(), x))); ba.commit(buffer_copy(d, buffer(s.data(), x)));
} }
BEAST_EXPECT(ba.size() == 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()); BEAST_EXPECT(buffer_size(ba.data()) == ba.size());
{ {
auto d = ba.prepare(x); auto d = ba.prepare(x);
@ -89,7 +89,7 @@ public:
} }
ba.commit(1); ba.commit(1);
BEAST_EXPECT(ba.size() == x + y); 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()); BEAST_EXPECT(buffer_size(ba.data()) == ba.size());
{ {
auto d = ba.prepare(x); auto d = ba.prepare(x);
@ -109,7 +109,6 @@ public:
} }
ba.commit(2); ba.commit(2);
BEAST_EXPECT(ba.size() == x + y + z); BEAST_EXPECT(ba.size() == x + y + z);
BEAST_EXPECT(ba.max_size() == 0);
BEAST_EXPECT(buffer_size(ba.data()) == ba.size()); BEAST_EXPECT(buffer_size(ba.data()) == ba.size());
BEAST_EXPECT(buffers_to_string(ba.data()) == s); BEAST_EXPECT(buffers_to_string(ba.data()) == s);
ba.consume(t); ba.consume(t);