common/IoUtil.cpp | 7 ++++++- common/Protocol.hpp | 4 +++- wsd/LOOLWebSocket.hpp | 9 +++++++-- 3 files changed, 16 insertions(+), 4 deletions(-)
New commits: commit 7451a48511e22586337be14721f1b8317c5c7e26 Author: Tor Lillqvist <[email protected]> Date: Fri Dec 2 16:51:11 2016 +0200 Handle return value -1 from our LOOLWebSocket::receiveFrame() It doesn't mean anything is wrong or that the connection would be in some invalid or closed state, but just that we didn't actually receive any "interesting" frame that could be handled in the caller. diff --git a/common/IoUtil.cpp b/common/IoUtil.cpp index b9b91cd..a8cd003 100644 --- a/common/IoUtil.cpp +++ b/common/IoUtil.cpp @@ -90,7 +90,12 @@ void SocketProcessor(const std::shared_ptr<LOOLWebSocket>& ws, continue; } - if (n <= 0 || ((flags & WebSocket::FRAME_OP_BITMASK) == WebSocket::FRAME_OP_CLOSE)) + if (n == -1) + { + LOG_DBG("SocketProcessor [" << name << "]: was not an interesting frame, nothing to do here"); + continue; + } + else if (n == 0 || ((flags & WebSocket::FRAME_OP_BITMASK) == WebSocket::FRAME_OP_CLOSE)) { LOG_WRN("SocketProcessor [" << name << "]: Connection closed."); closeFrame(); commit 7263491ea61b8f7eb577748d9e32a97a306f11c8 Author: Tor Lillqvist <[email protected]> Date: Fri Dec 2 16:43:39 2016 +0200 Document return value of our LOOLWebSocket::receiveFrame() Especially the -1 return value, which is different from what the Poco WebSocket::receiveFrame() can return. diff --git a/wsd/LOOLWebSocket.hpp b/wsd/LOOLWebSocket.hpp index 36efab2..d29d429 100644 --- a/wsd/LOOLWebSocket.hpp +++ b/wsd/LOOLWebSocket.hpp @@ -78,6 +78,10 @@ public: /// Wrapper for Poco::Net::WebSocket::receiveFrame() that handles PING frames /// (by replying with a PONG frame) and PONG frames. PONG frames are ignored. + + /// Returns number of bytes received, or 0 if the Poco receiveFrame() returned 0, + /// or -1 if no "interesting" (not PING or PONG) frame was actually received). + /// Should we also factor out the handling of non-final and continuation frames into this? int receiveFrame(char* buffer, const int length, int& flags) { commit 2a307c3ef3eedaea8637883198e676819bc20642 Author: Tor Lillqvist <[email protected]> Date: Fri Dec 2 14:32:27 2016 +0200 Show also the contents of PING and PONG frames in getAbbreviatedFrameDump() diff --git a/common/Protocol.hpp b/common/Protocol.hpp index da64ee3..404e01b 100644 --- a/common/Protocol.hpp +++ b/common/Protocol.hpp @@ -222,7 +222,9 @@ namespace LOOLProtocol if (length > 0 && ((flags & Poco::Net::WebSocket::FRAME_OP_BITMASK) == Poco::Net::WebSocket::FRAME_OP_TEXT || - (flags & Poco::Net::WebSocket::FRAME_OP_BITMASK) == Poco::Net::WebSocket::FRAME_OP_BINARY)) + (flags & Poco::Net::WebSocket::FRAME_OP_BITMASK) == Poco::Net::WebSocket::FRAME_OP_BINARY || + (flags & Poco::Net::WebSocket::FRAME_OP_BITMASK) == Poco::Net::WebSocket::FRAME_OP_PING || + (flags & Poco::Net::WebSocket::FRAME_OP_BITMASK) == Poco::Net::WebSocket::FRAME_OP_PONG)) result << ": '" << getAbbreviatedMessage(message, length) << "'"; return result.str(); } commit f144dd9f05882684a1f041527377050e122496c2 Author: Tor Lillqvist <[email protected]> Date: Fri Dec 2 14:32:11 2016 +0200 Log also the frame as received diff --git a/wsd/LOOLWebSocket.hpp b/wsd/LOOLWebSocket.hpp index d4d43b3..36efab2 100644 --- a/wsd/LOOLWebSocket.hpp +++ b/wsd/LOOLWebSocket.hpp @@ -91,6 +91,7 @@ public: while (poll(waitTime, Poco::Net::Socket::SELECT_READ)) { const int n = Poco::Net::WebSocket::receiveFrame(buffer, length, flags); + LOG_TRC("Got frame: " << LOOLProtocol::getAbbreviatedFrameDump(buffer, n, flags)); if ((flags & WebSocket::FRAME_OP_BITMASK) == WebSocket::FRAME_OP_PING) { sendFrame(buffer, n, WebSocket::FRAME_FLAG_FIN | WebSocket::FRAME_OP_PONG); commit ffbc9baccceacb1940f209a21a563f8105283204 Author: Tor Lillqvist <[email protected]> Date: Fri Dec 2 14:30:53 2016 +0200 Use getAbbreviatedFrameDump() instead of getAbbreviatedMessage() when logging The more information the better, when tracking problems. diff --git a/wsd/LOOLWebSocket.hpp b/wsd/LOOLWebSocket.hpp index 373b41a..d4d43b3 100644 --- a/wsd/LOOLWebSocket.hpp +++ b/wsd/LOOLWebSocket.hpp @@ -131,11 +131,11 @@ public: if (result != length) { LOG_ERR("Sent incomplete message, expected " << length << " bytes but sent " << result << - " while sending: " << LOOLProtocol::getAbbreviatedMessage(buffer, length)); + " while sending: " << LOOLProtocol::getAbbreviatedFrameDump(buffer, length, flags)); } else { - LOG_TRC("Sent frame: " << LOOLProtocol::getAbbreviatedMessage(buffer, length)); + LOG_TRC("Sent frame: " << LOOLProtocol::getAbbreviatedFrameDump(buffer, length, flags)); } return result; _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
