[Libreoffice-commits] online.git: loolwsd/LOOLWSD.cpp loolwsd/test
Henry Castro
hcastro at collabora.com
Sat Apr 16 17:31:26 UTC 2016
loolwsd/LOOLWSD.cpp | 9 ++++-----
loolwsd/test/httpwstest.cpp | 40 +++++++++++++++++++++++++---------------
2 files changed, 29 insertions(+), 20 deletions(-)
New commits:
commit a66e73aeb0789a87c6948e6c1e9a2fc3e13b3aa1
Author: Henry Castro <hcastro at collabora.com>
Date: Sat Apr 16 13:29:00 2016 -0400
loolwsd: fail when document broker cannot get a child
diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index a60d90d..802850b 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -543,10 +543,10 @@ private:
if (!child)
{
// Let the client know we can't serve now.
- response.setStatusAndReason(Poco::Net::HTTPResponse::HTTP_SERVICE_UNAVAILABLE);
- response.setContentLength(0);
- response.send();
- return;
+ status = "statusindicator: fail";
+ ws->sendFrame(status.data(), (int) status.size());
+ ws->shutdown();
+ throw WebSocketException("Failed to get new child. Client cannot serve now.", WebSocket::WS_ENDPOINT_GOING_AWAY);
}
// Set one we just created.
@@ -575,7 +575,6 @@ private:
if (!waitBridgeCompleted(session, docBroker))
{
- Log::error(session->getName() + ": Failed to connect to lokit process. Client cannot serve now.");
// Let the client know we can't serve now.
status = "statusindicator: fail";
ws->sendFrame(status.data(), (int) status.size());
diff --git a/loolwsd/test/httpwstest.cpp b/loolwsd/test/httpwstest.cpp
index 91dfb79..cdaeeee 100644
--- a/loolwsd/test/httpwstest.cpp
+++ b/loolwsd/test/httpwstest.cpp
@@ -209,29 +209,39 @@ void HTTPWSTest::testHandShake()
CPPUNIT_ASSERT(payload.compare(0, payload.size(), buffer, 0, bytes) == 0);
CPPUNIT_ASSERT(flags == Poco::Net::WebSocket::FRAME_TEXT);
- // After document broker finish searching it sends editlok
- // it should be at end on handshake
bytes = socket.receiveFrame(buffer, sizeof(buffer), flags);
- CPPUNIT_ASSERT(prefixEdit.compare(0, prefixEdit.size(), buffer, 0, prefixEdit.size()) == 0);
- CPPUNIT_ASSERT(flags == Poco::Net::WebSocket::FRAME_TEXT);
-
- payload = "statusindicator: connect";
- bytes = socket.receiveFrame(buffer, sizeof(buffer), flags);
- CPPUNIT_ASSERT_EQUAL((int) payload.size(), bytes);
- CPPUNIT_ASSERT(payload.compare(0, payload.size(), buffer, 0, bytes) == 0);
- CPPUNIT_ASSERT(flags == Poco::Net::WebSocket::FRAME_TEXT);
-
- bytes = socket.receiveFrame(buffer, sizeof(buffer), flags);
- if (std::strstr(buffer, fail))
+ if (!std::strstr(buffer, fail))
{
- payload = "statusindicator: fail";
+ // After document broker finish searching it sends editlok
+ // it should be at end on handshake
+ CPPUNIT_ASSERT(prefixEdit.compare(0, prefixEdit.size(), buffer, 0, prefixEdit.size()) == 0);
+ CPPUNIT_ASSERT(flags == Poco::Net::WebSocket::FRAME_TEXT);
+
+ payload = "statusindicator: connect";
+ bytes = socket.receiveFrame(buffer, sizeof(buffer), flags);
CPPUNIT_ASSERT_EQUAL((int) payload.size(), bytes);
CPPUNIT_ASSERT(payload.compare(0, payload.size(), buffer, 0, bytes) == 0);
CPPUNIT_ASSERT(flags == Poco::Net::WebSocket::FRAME_TEXT);
+
+ bytes = socket.receiveFrame(buffer, sizeof(buffer), flags);
+ if (!std::strstr(buffer, fail))
+ {
+ payload = "statusindicator: ready";
+ CPPUNIT_ASSERT_EQUAL((int) payload.size(), bytes);
+ CPPUNIT_ASSERT(payload.compare(0, payload.size(), buffer, 0, bytes) == 0);
+ CPPUNIT_ASSERT(flags == Poco::Net::WebSocket::FRAME_TEXT);
+ }
+ else
+ {
+ payload = "statusindicator: fail";
+ CPPUNIT_ASSERT_EQUAL((int) payload.size(), bytes);
+ CPPUNIT_ASSERT(payload.compare(0, payload.size(), buffer, 0, bytes) == 0);
+ CPPUNIT_ASSERT(flags == Poco::Net::WebSocket::FRAME_TEXT);
+ }
}
else
{
- payload = "statusindicator: ready";
+ payload = "statusindicator: fail";
CPPUNIT_ASSERT_EQUAL((int) payload.size(), bytes);
CPPUNIT_ASSERT(payload.compare(0, payload.size(), buffer, 0, bytes) == 0);
CPPUNIT_ASSERT(flags == Poco::Net::WebSocket::FRAME_TEXT);
More information about the Libreoffice-commits
mailing list