summaryrefslogtreecommitdiffhomepage
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
parent63896903e8dd1f2a08c4ba7a9817fef433da6c68 (diff)
Fix websocket session leakv1.20
-rw-r--r--debian/changelog6
-rw-r--r--websocket.cpp11
2 files changed, 10 insertions, 7 deletions
diff --git a/debian/changelog b/debian/changelog
index eff5c89..94c4ef4 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+webserver (1.20) unstable; urgency=medium
+
+ * Handle session close by browsers to prevent connection leak
+
+ -- Roland Reichwein <mail@reichwein.it> Fri, 10 Feb 2023 18:40:01 +0100
+
webserver (1.19) unstable; urgency=medium
* Websocket bugfix: close remaining connection, prevent leak
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");