summaryrefslogtreecommitdiffhomepage
path: root/websocket.cpp
diff options
context:
space:
mode:
authorRoland Reichwein <mail@reichwein.it>2023-02-10 18:40:43 +0100
committerRoland Reichwein <mail@reichwein.it>2023-02-10 18:40:43 +0100
commit95981a55ca7a4cccadc24315eb6cbf892bd07b3f (patch)
treeed6a3bb43e5dae8f326e4da95be53ae357b741a7 /websocket.cpp
parent63896903e8dd1f2a08c4ba7a9817fef433da6c68 (diff)
Fix websocket session leakv1.20
Diffstat (limited to 'websocket.cpp')
-rw-r--r--websocket.cpp11
1 files changed, 4 insertions, 7 deletions
diff --git a/websocket.cpp b/websocket.cpp
index d361ec1..8d4d27c 100644
--- a/websocket.cpp
+++ b/websocket.cpp
@@ -67,15 +67,16 @@ public:
void fail(boost::beast::error_code ec, char const* what)
{
- if (ec == websocket::error::closed)
- return;
-
boost::beast::error_code ec2;
+
if (auto& ws_in{derived().ws_in()}; ws_in.is_open())
ws_in.close(beast::websocket::close_code::going_away, ec2);
if (auto& ws_app{ws_app_}; ws_app.is_open())
ws_app.close(beast::websocket::close_code::going_away, ec2);
+ if (ec == websocket::error::closed)
+ return;
+
std::cerr << what << ": " << ec.message() << "\n";
}
@@ -191,10 +192,6 @@ private:
{
boost::ignore_unused(bytes_transferred);
- // This indicates that the websocket_session was closed
- if (ec == websocket::error::closed)
- return;
-
if (ec) {
// not error::closed as above, but no other strategy known
return fail(ec, "read in");