summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-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");