Fix stream::read_size_hint calculation

This commit is contained in:
Vinnie Falco
2017-08-02 19:36:31 -07:00
parent 576edfaaed
commit 028fda0237
2 changed files with 6 additions and 2 deletions

View File

@@ -13,6 +13,7 @@ WebSocket:
* Refactor fail/clode code
* Call do_fail from read_some
* eof on accept returns error::closed
* Fix stream::read_size_hint calculation
--------------------------------------------------------------------------------

View File

@@ -98,8 +98,11 @@ read_size_hint(
buffer.max_size(), clamp(rd_.remain));
}
}
return (std::min)(buffer.max_size(), (std::max)(
(std::max)(+tcp_frame_size, clamp(rd_.remain)),
return (std::min)(
buffer.max_size() - buffer.size(),
(std::max)((std::max)(
+tcp_frame_size,
clamp(rd_.remain)),
buffer.capacity() - buffer.size()));
}