From fd10d1c9f85caa65ae5681e9a126a3b36266b019 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20Budiseli=C4=87?= Date: Mon, 16 Oct 2023 15:41:12 +0200 Subject: [PATCH] Fix CPU 100% usage by websocket error handling improvement (#1327) --- src/communication/websocket/session.cpp | 7 ++++++- src/communication/websocket/session.hpp | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/communication/websocket/session.cpp b/src/communication/websocket/session.cpp index 540cb00c7..13c788ddd 100644 --- a/src/communication/websocket/session.cpp +++ b/src/communication/websocket/session.cpp @@ -1,4 +1,4 @@ -// Copyright 2022 Memgraph Ltd. +// Copyright 2023 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -175,6 +175,11 @@ void Session::OnRead(const boost::beast::error_code ec, const size_t /*bytes_tra return; } + if (ec) { + LogError(ec, "read"); + return; + } + if (!IsAuthenticated()) { auto response = nlohmann::json(); auto auth_failed = [this, &response](const std::string &message) { diff --git a/src/communication/websocket/session.hpp b/src/communication/websocket/session.hpp index 0e5c92aa3..1b4283611 100644 --- a/src/communication/websocket/session.hpp +++ b/src/communication/websocket/session.hpp @@ -1,4 +1,4 @@ -// Copyright 2022 Memgraph Ltd. +// Copyright 2023 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source