[Libreoffice-commits] online.git: common/LOOLWebSocket.hpp common/MessageQueue.cpp common/Protocol.hpp common/Util.cpp kit/ChildSession.cpp test/helpers.hpp test/httpcrashtest.cpp test/UnitSession.cpp tools/Connect.cpp
Michael Meeks (via logerrit)
logerrit at kemper.freedesktop.org
Sat Apr 18 16:29:22 UTC 2020
common/LOOLWebSocket.hpp | 38 +++++++++++++++++++++++++++++++++++---
common/MessageQueue.cpp | 2 +-
common/Protocol.hpp | 34 ----------------------------------
common/Util.cpp | 2 +-
kit/ChildSession.cpp | 1 +
test/UnitSession.cpp | 10 +++++-----
test/helpers.hpp | 8 ++++----
test/httpcrashtest.cpp | 2 +-
tools/Connect.cpp | 2 +-
9 files changed, 49 insertions(+), 50 deletions(-)
New commits:
commit 3e4ac31c7c6ba95eab12585e0550372b0a39973f
Author: Michael Meeks <michael.meeks at collabora.com>
AuthorDate: Sat Apr 18 11:55:50 2020 +0100
Commit: Michael Meeks <michael.meeks at collabora.com>
CommitDate: Sat Apr 18 18:29:04 2020 +0200
killpoco: remove WebSocket includes from a couple of places.
Change-Id: I06740cd978bec8e6a74beb8ed9ef8f4f970a2535
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/92470
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
Reviewed-by: Michael Meeks <michael.meeks at collabora.com>
diff --git a/common/LOOLWebSocket.hpp b/common/LOOLWebSocket.hpp
index a99c3afb0..627b89a5e 100644
--- a/common/LOOLWebSocket.hpp
+++ b/common/LOOLWebSocket.hpp
@@ -62,7 +62,7 @@ public:
if (n <= 0)
LOG_TRC("Got nothing (" << n << ")");
else
- LOG_TRC("Got frame: " << LOOLProtocol::getAbbreviatedFrameDump(buffer, n, flags));
+ LOG_TRC("Got frame: " << getAbbreviatedFrameDump(buffer, n, flags));
if ((flags & WebSocket::FRAME_OP_BITMASK) == WebSocket::FRAME_OP_CLOSE)
{
@@ -103,11 +103,11 @@ public:
if (result != length)
{
LOG_ERR("Sent incomplete message, expected " << length << " bytes but sent " << result <<
- " for: " << LOOLProtocol::getAbbreviatedFrameDump(buffer, length, flags));
+ " for: " << getAbbreviatedFrameDump(buffer, length, flags));
}
else
{
- LOG_TRC("Sent frame: " << LOOLProtocol::getAbbreviatedFrameDump(buffer, length, flags));
+ LOG_TRC("Sent frame: " << getAbbreviatedFrameDump(buffer, length, flags));
}
return result;
@@ -154,6 +154,38 @@ public:
}
}
}
+
+ // Return a string dump of a WebSocket frame: Its opcode, length, first line (if present),
+ // flags. For human-readable logging purposes. Format not guaranteed to be stable. Not to be
+ // inspected programmatically.
+ static inline
+ std::string getAbbreviatedFrameDump(const char *message, const int length, const int flags)
+ {
+ std::ostringstream result;
+ switch (flags & Poco::Net::WebSocket::FRAME_OP_BITMASK)
+ {
+#define CASE(x) case Poco::Net::WebSocket::FRAME_OP_##x: result << #x; break
+ CASE(CONT);
+ CASE(TEXT);
+ CASE(BINARY);
+ CASE(CLOSE);
+ CASE(PING);
+ CASE(PONG);
+#undef CASE
+ default:
+ result << Poco::format("%#x", flags);
+ break;
+ }
+ result << " " << std::setw(3) << length << " bytes";
+
+ 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_PING ||
+ (flags & Poco::Net::WebSocket::FRAME_OP_BITMASK) == Poco::Net::WebSocket::FRAME_OP_PONG))
+ result << ": '" << LOOLProtocol::getAbbreviatedMessage(message, length) << "'";
+ return result.str();
+ }
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/common/MessageQueue.cpp b/common/MessageQueue.cpp
index 5482b4f79..3e5cb08d2 100644
--- a/common/MessageQueue.cpp
+++ b/common/MessageQueue.cpp
@@ -10,7 +10,7 @@
#include <config.h>
#include "MessageQueue.hpp"
-
+#include <climits>
#include <algorithm>
#include <Poco/JSON/JSON.h>
diff --git a/common/Protocol.hpp b/common/Protocol.hpp
index c10e9ae52..56cff7896 100644
--- a/common/Protocol.hpp
+++ b/common/Protocol.hpp
@@ -19,8 +19,6 @@
#include <string>
#include <vector>
-#include <Poco/Net/WebSocket.h>
-
#include <Util.hpp>
#define LOK_USE_UNSTABLE_API
@@ -311,38 +309,6 @@ namespace LOOLProtocol
{
return getAbbreviatedMessage(message.data(), message.size());
}
-
- // Return a string dump of a WebSocket frame: Its opcode, length, first line (if present),
- // flags. For human-readable logging purposes. Format not guaranteed to be stable. Not to be
- // inspected programmatically.
- inline
- std::string getAbbreviatedFrameDump(const char *message, const int length, const int flags)
- {
- std::ostringstream result;
- switch (flags & Poco::Net::WebSocket::FRAME_OP_BITMASK)
- {
-#define CASE(x) case Poco::Net::WebSocket::FRAME_OP_##x: result << #x; break
- CASE(CONT);
- CASE(TEXT);
- CASE(BINARY);
- CASE(CLOSE);
- CASE(PING);
- CASE(PONG);
-#undef CASE
- default:
- result << Poco::format("%#x", flags);
- break;
- }
- result << " " << std::setw(3) << length << " bytes";
-
- 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_PING ||
- (flags & Poco::Net::WebSocket::FRAME_OP_BITMASK) == Poco::Net::WebSocket::FRAME_OP_PONG))
- result << ": '" << getAbbreviatedMessage(message, length) << "'";
- return result.str();
- }
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/common/Util.cpp b/common/Util.cpp
index 7b71da598..e4d19adb1 100644
--- a/common/Util.cpp
+++ b/common/Util.cpp
@@ -25,6 +25,7 @@
#include <sys/types.h>
#include <unistd.h>
#include <dirent.h>
+#include <fcntl.h>
#include <atomic>
#include <cassert>
@@ -51,7 +52,6 @@
#include <Poco/JSON/JSON.h>
#include <Poco/JSON/Object.h>
#include <Poco/JSON/Parser.h>
-#include <Poco/Net/WebSocket.h>
#include <Poco/Process.h>
#include <Poco/RandomStream.h>
#include <Poco/TemporaryFile.h>
diff --git a/kit/ChildSession.cpp b/kit/ChildSession.cpp
index 780efb18f..cfc7c8baa 100644
--- a/kit/ChildSession.cpp
+++ b/kit/ChildSession.cpp
@@ -11,6 +11,7 @@
#include "ChildSession.hpp"
+#include <climits>
#include <fstream>
#include <sstream>
diff --git a/test/UnitSession.cpp b/test/UnitSession.cpp
index 7e11c2128..f8b859fa1 100644
--- a/test/UnitSession.cpp
+++ b/test/UnitSession.cpp
@@ -110,18 +110,18 @@ UnitBase::TestResult UnitSession::testHandshake()
int flags = 0;
char buffer[1024] = { 0 };
int bytes = socket.receiveFrame(buffer, sizeof(buffer), flags);
- TST_LOG("Got " << LOOLProtocol::getAbbreviatedFrameDump(buffer, bytes, flags));
+ TST_LOG("Got " << LOOLWebSocket::getAbbreviatedFrameDump(buffer, bytes, flags));
LOK_ASSERT_EQUAL(std::string("statusindicator: find"), std::string(buffer, bytes));
bytes = socket.receiveFrame(buffer, sizeof(buffer), flags);
- TST_LOG("Got " << LOOLProtocol::getAbbreviatedFrameDump(buffer, bytes, flags));
+ TST_LOG("Got " << LOOLWebSocket::getAbbreviatedFrameDump(buffer, bytes, flags));
if (bytes > 0 && !std::strstr(buffer, "error:"))
{
LOK_ASSERT_EQUAL(std::string("statusindicator: connect"),
std::string(buffer, bytes));
bytes = socket.receiveFrame(buffer, sizeof(buffer), flags);
- TST_LOG("Got " << LOOLProtocol::getAbbreviatedFrameDump(buffer, bytes, flags));
+ TST_LOG("Got " << LOOLWebSocket::getAbbreviatedFrameDump(buffer, bytes, flags));
if (!std::strstr(buffer, "error:"))
{
LOK_ASSERT_EQUAL(std::string("statusindicator: ready"),
@@ -134,7 +134,7 @@ UnitBase::TestResult UnitSession::testHandshake()
// close frame message
bytes = socket.receiveFrame(buffer, sizeof(buffer), flags);
- TST_LOG("Got " << LOOLProtocol::getAbbreviatedFrameDump(buffer, bytes, flags));
+ TST_LOG("Got " << LOOLWebSocket::getAbbreviatedFrameDump(buffer, bytes, flags));
LOK_ASSERT((flags & Poco::Net::WebSocket::FRAME_OP_BITMASK)
== Poco::Net::WebSocket::FRAME_OP_CLOSE);
}
@@ -146,7 +146,7 @@ UnitBase::TestResult UnitSession::testHandshake()
// close frame message
bytes = socket.receiveFrame(buffer, sizeof(buffer), flags);
- TST_LOG("Got " << LOOLProtocol::getAbbreviatedFrameDump(buffer, bytes, flags));
+ TST_LOG("Got " << LOOLWebSocket::getAbbreviatedFrameDump(buffer, bytes, flags));
LOK_ASSERT((flags & Poco::Net::WebSocket::FRAME_OP_BITMASK)
== Poco::Net::WebSocket::FRAME_OP_CLOSE);
}
diff --git a/test/helpers.hpp b/test/helpers.hpp
index 3322fc5b0..341c5621c 100644
--- a/test/helpers.hpp
+++ b/test/helpers.hpp
@@ -273,7 +273,7 @@ int getErrorCode(LOOLWebSocket& ws, std::string& message, const std::string& tes
do
{
bytes = ws.receiveFrame(buffer.begin(), READ_BUFFER_SIZE, flags);
- TST_LOG("Got " << LOOLProtocol::getAbbreviatedFrameDump(buffer.begin(), bytes, flags));
+ TST_LOG("Got " << LOOLWebSocket::getAbbreviatedFrameDump(buffer.begin(), bytes, flags));
std::this_thread::sleep_for(std::chrono::microseconds(POLL_TIMEOUT_MICRO_S));
}
while (bytes > 0 && (flags & Poco::Net::WebSocket::FRAME_OP_BITMASK) != Poco::Net::WebSocket::FRAME_OP_CLOSE);
@@ -325,7 +325,7 @@ std::vector<char> getResponseMessage(LOOLWebSocket& ws, const std::string& prefi
if (LOOLProtocol::matchPrefix(prefix, message))
{
TST_LOG("[" << prefix << "] Matched " <<
- LOOLProtocol::getAbbreviatedFrameDump(response.data(), bytes, flags));
+ LOOLWebSocket::getAbbreviatedFrameDump(response.data(), bytes, flags));
return response;
}
}
@@ -349,7 +349,7 @@ std::vector<char> getResponseMessage(LOOLWebSocket& ws, const std::string& prefi
}
TST_LOG("[" << prefix << "] Ignored " <<
- LOOLProtocol::getAbbreviatedFrameDump(response.data(), bytes, flags));
+ LOOLWebSocket::getAbbreviatedFrameDump(response.data(), bytes, flags));
}
}
}
@@ -539,7 +539,7 @@ void SocketProcessor(const std::string& testname,
}
n = socket->receiveFrame(buffer, sizeof(buffer), flags);
- TST_LOG("Got " << LOOLProtocol::getAbbreviatedFrameDump(buffer, n, flags));
+ TST_LOG("Got " << LOOLWebSocket::getAbbreviatedFrameDump(buffer, n, flags));
if (n > 0 && (flags & Poco::Net::WebSocket::FRAME_OP_BITMASK) != Poco::Net::WebSocket::FRAME_OP_CLOSE)
{
if (!handler(std::string(buffer, n)))
diff --git a/test/httpcrashtest.cpp b/test/httpcrashtest.cpp
index e824c1cb9..3a69a96ba 100644
--- a/test/httpcrashtest.cpp
+++ b/test/httpcrashtest.cpp
@@ -166,7 +166,7 @@ void HTTPCrashTest::testCrashKit()
int flags;
char buffer[READ_BUFFER_SIZE];
const int bytes = socket->receiveFrame(buffer, sizeof(buffer), flags);
- TST_LOG(testname << "Got " << LOOLProtocol::getAbbreviatedFrameDump(buffer, bytes, flags));
+ TST_LOG(testname << "Got " << LOOLWebSocket::getAbbreviatedFrameDump(buffer, bytes, flags));
// While we expect no more messages after shutdown call, apparently
// sometimes we _do_ get data. Even when the receiveFrame in the loop
diff --git a/tools/Connect.cpp b/tools/Connect.cpp
index a150bdf99..0a115960b 100644
--- a/tools/Connect.cpp
+++ b/tools/Connect.cpp
@@ -84,7 +84,7 @@ public:
{
{
std::unique_lock<std::mutex> lock(coutMutex);
- std::cout << "Got " << getAbbreviatedFrameDump(buffer, n, flags) << std::endl;
+ std::cout << "Got " << LOOLWebSocket::getAbbreviatedFrameDump(buffer, n, flags) << std::endl;
}
std::string firstLine = getFirstLine(buffer, n);
More information about the Libreoffice-commits
mailing list