From c08e6367110e4198e601c2b77d35384a95a02eff Mon Sep 17 00:00:00 2001 From: Richard Hodges Date: Mon, 16 Mar 2020 20:13:52 +0100 Subject: [PATCH] Refactor websocket read: Some readability improvements ref #1618 --- CHANGELOG.md | 1 + include/boost/beast/websocket/impl/read.hpp | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ba917082..540c40f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ Version XXX: * Remove CODE_OF_CONDUCT.md +* Refactor websocket read -------------------------------------------------------------------------------- diff --git a/include/boost/beast/websocket/impl/read.hpp b/include/boost/beast/websocket/impl/read.hpp index 86c8940f..4e03baae 100644 --- a/include/boost/beast/websocket/impl/read.hpp +++ b/include/boost/beast/websocket/impl/read.hpp @@ -432,7 +432,9 @@ public: impl.rd_size += bytes_transferred; } } - impl.rd_done = impl.rd_remain == 0 && impl.rd_fh.fin; + BOOST_ASSERT( ! impl.rd_done ); + if( impl.rd_remain == 0 && impl.rd_fh.fin ) + impl.rd_done = true; } else { @@ -1142,7 +1144,9 @@ loop: impl.rd_size += bytes_transferred; } } - impl.rd_done = impl.rd_remain == 0 && impl.rd_fh.fin; + BOOST_ASSERT( ! impl.rd_done ); + if( impl.rd_remain == 0 && impl.rd_fh.fin ) + impl.rd_done = true; } else {