loolwsd/DocumentBroker.cpp | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-)
New commits: commit 827c0865e7683eb29016fb80c909f4d4316a0ae2 Author: Ashod Nakashian <ashod.nakash...@collabora.co.uk> Date: Sat Nov 19 10:04:42 2016 -0500 loolwsd: handle exceptions from socket calls Change-Id: I99e1df249e02f18d5b0c1b1c6a701e522baad87b Reviewed-on: https://gerrit.libreoffice.org/30999 Reviewed-by: Ashod Nakashian <ashnak...@gmail.com> Tested-by: Ashod Nakashian <ashnak...@gmail.com> diff --git a/loolwsd/DocumentBroker.cpp b/loolwsd/DocumentBroker.cpp index 95fdd4d..9e4cc3d 100644 --- a/loolwsd/DocumentBroker.cpp +++ b/loolwsd/DocumentBroker.cpp @@ -584,7 +584,14 @@ void DocumentBroker::alertAllUsers(const std::string& msg) for (auto& it : _sessions) { - it.second->sendTextFrame(msg); + try + { + it.second->sendTextFrame(msg); + } + catch (const std::exception& ex) + { + LOG_ERR("Error while alerting all users [" << msg << "]: " << ex.what()); + } } } @@ -926,7 +933,14 @@ void DocumentBroker::childSocketTerminated() // For now, close the connections to cleanup. for (auto& pair : _sessions) { - pair.second->shutdown(Poco::Net::WebSocket::WS_ENDPOINT_GOING_AWAY); + try + { + pair.second->shutdown(Poco::Net::WebSocket::WS_ENDPOINT_GOING_AWAY); + } + catch (const std::exception& ex) + { + LOG_ERR("Error while terminating client connection [" << pair.first << "]: " << ex.what()); + } } } @@ -940,9 +954,16 @@ void DocumentBroker::terminateChild(std::unique_lock<std::mutex>& lock, const st // Close all running sessions for (auto& pair : _sessions) { - // See protocol.txt for this application-level close frame - pair.second->sendTextFrame("close: " + closeReason); - pair.second->shutdown(Poco::Net::WebSocket::WS_ENDPOINT_GOING_AWAY, closeReason); + try + { + // See protocol.txt for this application-level close frame. + pair.second->sendTextFrame("close: " + closeReason); + pair.second->shutdown(Poco::Net::WebSocket::WS_ENDPOINT_GOING_AWAY, closeReason); + } + catch (const std::exception& ex) + { + LOG_ERR("Error while terminating client connection [" << pair.first << "]: " << ex.what()); + } } // First flag to stop as it might be waiting on our lock _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits