loolwsd/LOOLWSD.cpp | 15 +++++++-------- loolwsd/UserMessages.hpp | 2 -- loolwsd/test/httpwserror.cpp | 2 -- 3 files changed, 7 insertions(+), 12 deletions(-)
New commits: commit e7009c12e10a472741e0a93b32cf51bff842dd27 Author: Henry Castro <[email protected]> Date: Mon Oct 10 22:28:56 2016 -0400 loolwsd: websocket shutdown cleanup diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp index 7d181fb..bb1a9c6 100644 --- a/loolwsd/LOOLWSD.cpp +++ b/loolwsd/LOOLWSD.cpp @@ -180,7 +180,6 @@ static inline void lcl_shutdownLimitReached(WebSocket& ws) { const std::string error = Poco::format(PAYLOAD_UNAVALABLE_LIMIT_REACHED, MAX_DOCUMENTS, MAX_CONNECTIONS); - const std::string close = Poco::format(SERVICE_UNAVALABLE_LIMIT_REACHED, static_cast<int>(WebSocket::WS_POLICY_VIOLATION)); /* loleaflet sends loolclient, load and partrectangles message immediately after web socket handshake, so closing web socket fails loading page in @@ -202,7 +201,7 @@ void lcl_shutdownLimitReached(WebSocket& ws) if (--retries == 4) { ws.sendFrame(error.data(), error.size()); - ws.shutdown(WebSocket::WS_POLICY_VIOLATION, close); + ws.shutdown(WebSocket::WS_POLICY_VIOLATION, ""); } } while (retries > 0 && (flags & WebSocket::FRAME_OP_BITMASK) != WebSocket::FRAME_OP_CLOSE); @@ -210,7 +209,7 @@ void lcl_shutdownLimitReached(WebSocket& ws) catch (Exception&) { ws.sendFrame(error.data(), error.size()); - ws.shutdown(WebSocket::WS_POLICY_VIOLATION, close); + ws.shutdown(WebSocket::WS_POLICY_VIOLATION, ""); } } @@ -835,8 +834,8 @@ private: // something wrong, with internal exceptions Log::trace("Abnormal close handshake."); session->closeFrame(); - ws->shutdown(WebSocket::WS_ENDPOINT_GOING_AWAY, SERVICE_UNAVALABLE_INTERNAL_ERROR); - session->shutdownPeer(WebSocket::WS_ENDPOINT_GOING_AWAY, SERVICE_UNAVALABLE_INTERNAL_ERROR); + ws->shutdown(WebSocket::WS_ENDPOINT_GOING_AWAY, ""); + session->shutdownPeer(WebSocket::WS_ENDPOINT_GOING_AWAY, ""); } } @@ -985,7 +984,7 @@ public: const std::string msg = std::string("error: ") + exc.what(); ws->sendFrame(msg.data(), msg.size()); // abnormal close frame handshake - ws->shutdown(WebSocket::WS_ENDPOINT_GOING_AWAY, msg); + ws->shutdown(WebSocket::WS_ENDPOINT_GOING_AWAY, ""); } catch (const std::exception& exc2) { @@ -1199,8 +1198,8 @@ public: // something wrong, with internal exceptions Log::trace("Abnormal close handshake."); session->closeFrame(); - ws->shutdown(WebSocket::WS_ENDPOINT_GOING_AWAY, SERVICE_UNAVALABLE_INTERNAL_ERROR); - session->shutdownPeer(WebSocket::WS_ENDPOINT_GOING_AWAY, SERVICE_UNAVALABLE_INTERNAL_ERROR); + ws->shutdown(WebSocket::WS_ENDPOINT_GOING_AWAY, ""); + session->shutdownPeer(WebSocket::WS_ENDPOINT_GOING_AWAY, ""); } } catch (const Exception& exc) diff --git a/loolwsd/UserMessages.hpp b/loolwsd/UserMessages.hpp index 36e6ad3..7883fc0 100644 --- a/loolwsd/UserMessages.hpp +++ b/loolwsd/UserMessages.hpp @@ -13,9 +13,7 @@ #define INCLUDED_USERMESSAGES_HPP //NOTE: For whatever reason Poco seems to trim the first character. - constexpr auto SERVICE_UNAVALABLE_INTERNAL_ERROR = " Service is unavailable. Please try again later and report to your administrator if the issue persists."; -constexpr auto SERVICE_UNAVALABLE_LIMIT_REACHED = "error: cmd=socket kind=close code=%d"; constexpr auto PAYLOAD_UNAVALABLE_LIMIT_REACHED = "error: cmd=socket kind=limitreached params=%d,%d"; #endif diff --git a/loolwsd/test/httpwserror.cpp b/loolwsd/test/httpwserror.cpp index 8e7769d..509046c 100644 --- a/loolwsd/test/httpwserror.cpp +++ b/loolwsd/test/httpwserror.cpp @@ -103,7 +103,6 @@ void HTTPWSError::testMaxDocuments() sendTextFrame(socket, "partpagerectangles "); statusCode = getErrorCode(socket, message); CPPUNIT_ASSERT_EQUAL(static_cast<Poco::UInt16>(Poco::Net::WebSocket::WS_POLICY_VIOLATION), statusCode); - CPPUNIT_ASSERT_MESSAGE("Wrong error message ", message.find("error: cmd=socket kind=close") != std::string::npos); } catch (const Poco::Exception& exc) { @@ -144,7 +143,6 @@ void HTTPWSError::testMaxConnections() sendTextFrame(socketN, "partpagerectangles "); statusCode = getErrorCode(*socketN, message); CPPUNIT_ASSERT_EQUAL(static_cast<Poco::UInt16>(Poco::Net::WebSocket::WS_POLICY_VIOLATION), statusCode); - CPPUNIT_ASSERT_MESSAGE("Wrong error message ", message.find("error: cmd=socket kind=close") != std::string::npos); } catch (const Poco::Exception& exc) { _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
