[Libreoffice-commits] online.git: common/IoUtil.cpp common/Log.hpp

Ashod Nakashian ashod.nakashian at collabora.co.uk
Tue Dec 13 04:37:36 UTC 2016


 common/IoUtil.cpp |    9 ++-------
 common/Log.hpp    |    2 ++
 2 files changed, 4 insertions(+), 7 deletions(-)

New commits:
commit 4bc318fb8848490c0306ab9a5089a0a57c9ea6ba
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Mon Dec 12 23:31:00 2016 -0500

    loolwsd: LOG_CHECK to replace assertion when logging suffices
    
    Change-Id: I077c6394579f432c0aa9da053d20ccb9c6d31907
    Reviewed-on: https://gerrit.libreoffice.org/31934
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/common/IoUtil.cpp b/common/IoUtil.cpp
index 9958bfe..cc62244 100644
--- a/common/IoUtil.cpp
+++ b/common/IoUtil.cpp
@@ -110,7 +110,7 @@ void SocketProcessor(const std::shared_ptr<LOOLWebSocket>& ws,
                 continue;
             }
 
-            assert(n > 0);
+            LOG_CHECK(n > 0);
 
             const std::string firstLine = LOOLProtocol::getFirstLine(payload);
             if ((flags & WebSocket::FrameFlags::FRAME_FLAG_FIN) != WebSocket::FrameFlags::FRAME_FLAG_FIN)
@@ -164,12 +164,7 @@ void SocketProcessor(const std::shared_ptr<LOOLWebSocket>& ws,
                 }
             }
 
-            if (n <= 0 || (flags & WebSocket::FRAME_OP_BITMASK) == WebSocket::FRAME_OP_CLOSE)
-            {
-                closeFrame();
-                LOG_WRN("SocketProcessor [" << name << "]: Connection closed.");
-                break;
-            }
+            LOG_CHECK(n > 0);
 
             // Call the handler.
             const auto success = handler(payload);
diff --git a/common/Log.hpp b/common/Log.hpp
index ebd0ba4..ee7dc55 100644
--- a/common/Log.hpp
+++ b/common/Log.hpp
@@ -180,6 +180,8 @@ namespace Log
 #define LOG_FTL(X) if (Log::fatalEnabled()) { LOG_BODY("FTL", X); Log::logger().fatal(oss_.str()); }
 #define LOG_SFL(X) if (Log::errorEnabled()) { LOG_BODY("FTL", X << " (errno: " << std::strerror(errno) << ")"); Log::logger().fatal(oss_.str()); }
 
+#define LOG_CHECK(X) if (!(X)) { LOG_ERR("Check failed. Expected (" #X ")."); }
+
 #endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list