[Libreoffice-commits] online.git: loolwsd/LOOLWSD.cpp loolwsd/test loolwsd/UserMessages.hpp

Henry Castro hcastro at collabora.com
Tue Oct 11 02:28:16 UTC 2016


 loolwsd/LOOLWSD.cpp          |   15 +++++++--------
 loolwsd/UserMessages.hpp     |    2 --
 loolwsd/test/httpwserror.cpp |    2 --
 3 files changed, 7 insertions(+), 12 deletions(-)

New commits:
commit c62344db814fe351787316accf0faf53ee811db5
Author: Henry Castro <hcastro at collabora.com>
Date:   Mon Oct 10 22:28:56 2016 -0400

    loolwsd: websocket shutdown cleanup

diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index 2b3b205..79d1986 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -182,7 +182,6 @@ static inline
 void 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
@@ -204,7 +203,7 @@ void 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);
@@ -212,7 +211,7 @@ void shutdownLimitReached(WebSocket& ws)
     catch (Exception&)
     {
         ws.sendFrame(error.data(), error.size());
-        ws.shutdown(WebSocket::WS_POLICY_VIOLATION, close);
+        ws.shutdown(WebSocket::WS_POLICY_VIOLATION, "");
     }
 }
 
@@ -897,8 +896,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, "");
         }
     }
 
@@ -1050,7 +1049,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)
                     {
@@ -1275,8 +1274,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)
     {


More information about the Libreoffice-commits mailing list