summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAshod Nakashian <ashod.nakashian@collabora.co.uk>2016-11-09 00:47:42 -0500
committerAndras Timar <andras.timar@collabora.com>2016-11-09 09:40:54 +0100
commitb0191baac5a97393d2da23777e8caea63b269ea1 (patch)
tree0061d5ff22f53544faad72f536b3cf5a91956953
parentb7621ec05f332d005b8b55d60570092e65ce4b16 (diff)
loolwsd: no need to ping to check for live socket1.9.7
Ping message needs to be echoed and that messes up reading large messages that come in two parts. Luckily, it's not necessary to do so as it's sufficient to poll the state of the socket. It's true polling is less accurate as there is a timeout when a socket is disconnected, but that doesn't seem to be an issue in practice. Change-Id: I7a5744a621c4416b8f9d003871f6d613cc6ca7dc Reviewed-on: https://gerrit.libreoffice.org/30705 Reviewed-by: Ashod Nakashian <ashnakash@gmail.com> Tested-by: Ashod Nakashian <ashnakash@gmail.com> (cherry picked from commit 462f71a632a6fda87b195b893eda6c74a8fb295f)
-rw-r--r--loolwsd/DocumentBroker.hpp12
1 files changed, 4 insertions, 8 deletions
diff --git a/loolwsd/DocumentBroker.hpp b/loolwsd/DocumentBroker.hpp
index 2b0f16232..b5c1fa2e8 100644
--- a/loolwsd/DocumentBroker.hpp
+++ b/loolwsd/DocumentBroker.hpp
@@ -146,14 +146,10 @@ public:
{
try
{
- if (_pid > 1 && _ws && kill(_pid, 0) == 0)
- {
- // We don't care about the response (and shouldn't read here).
- _ws->sendFrame("PING", 4, Poco::Net::WebSocket::FRAME_OP_PING);
- LOG_DBG("Sent a PING.");
-
- return true;
- }
+ using namespace Poco::Net;
+ return (_pid > 1 && _ws && kill(_pid, 0) == 0 &&
+ _ws->poll(Poco::Timespan(0), Socket::SelectMode::SELECT_WRITE) &&
+ !_ws->poll(Poco::Timespan(0), Socket::SelectMode::SELECT_ERROR));
}
catch (const std::exception& exc)
{