wsd: close the socket when shutting down fails

Change-Id: Iea5c6a259272b6af881a5bfb27ffc31d2ad27793
Reviewed-on: https://gerrit.libreoffice.org/33424
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
This commit is contained in:
Ashod Nakashian 2017-01-20 16:34:10 -05:00 committed by Ashod Nakashian
parent 0fe580d9ab
commit b497fcfac5
2 changed files with 11 additions and 0 deletions

View file

@ -194,6 +194,7 @@ namespace
inline void shutdownLimitReached(LOOLWebSocket& ws) inline void shutdownLimitReached(LOOLWebSocket& ws)
{ {
const std::string error = Poco::format(PAYLOAD_UNAVAILABLE_LIMIT_REACHED, MAX_DOCUMENTS, MAX_CONNECTIONS); const std::string error = Poco::format(PAYLOAD_UNAVAILABLE_LIMIT_REACHED, MAX_DOCUMENTS, MAX_CONNECTIONS);
LOG_INF("Sending client limit-reached message: " << error);
/* loleaflet sends loolclient, load and partrectangles message immediately /* loleaflet sends loolclient, load and partrectangles message immediately
after web socket handshake, so closing web socket fails loading page in after web socket handshake, so closing web socket fails loading page in

View file

@ -223,6 +223,16 @@ public:
{ {
LOG_WRN("LOOLWebSocket::shutdown: Exception: " << exc.displayText() << LOG_WRN("LOOLWebSocket::shutdown: Exception: " << exc.displayText() <<
(exc.nested() ? " (" + exc.nested()->displayText() + ")" : "")); (exc.nested() ? " (" + exc.nested()->displayText() + ")" : ""));
// Just close it.
try
{
Poco::Net::WebSocket::close();
}
catch (const std::exception&)
{
// Nothing we can do.
}
} }
} }
}; };