wsd/LOOLWSD.cpp | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-)
New commits: commit 9c35ab156a62cdd5728649e9363beb80354f6822 Author: Ashod Nakashian <ashod.nakash...@collabora.co.uk> Date: Tue Jan 3 00:24:39 2017 -0500 wsd: exception-safe socket closing Change-Id: Id51e61195439e100758d63e5e3417e23b0f0fc53 Reviewed-on: https://gerrit.libreoffice.org/32678 Reviewed-by: Ashod Nakashian <ashnak...@gmail.com> Tested-by: Ashod Nakashian <ashnak...@gmail.com> diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp index 7b621e5..4798eaf 100644 --- a/wsd/LOOLWSD.cpp +++ b/wsd/LOOLWSD.cpp @@ -1100,13 +1100,6 @@ private: } } - if (SigUtil::isShuttingDown()) - { - std::lock_guard<std::mutex> lock(ClientWebSocketsMutex); - LOG_TRC("Capturing Client WS for [" << id << "]"); - ClientWebSockets.push_back(ws); - } - LOOLWSD::dumpEventTrace(docBroker->getJailId(), id, "EndSession: " + uri); LOG_INF("Finishing GET request handler for session [" << id << "]."); } @@ -1126,23 +1119,33 @@ private: LOG_ERR("Error in client request handler: " << exc.what()); } - if (session->isCloseFrame()) - { - LOG_TRC("Normal close handshake."); - // Client initiated close handshake - // respond close frame - ws->shutdown(); - } - else + try { - if (!SigUtil::isShuttingDown()) + if (session->isCloseFrame()) + { + LOG_TRC("Normal close handshake."); + // Client initiated close handshake + // respond close frame + ws->shutdown(); + } + else if (!SigUtil::isShuttingDown()) { // something wrong, with internal exceptions LOG_TRC("Abnormal close handshake."); session->closeFrame(); - // FIXME: handle exception thrown from here ? ... ws->shutdown(WebSocket::WS_ENDPOINT_GOING_AWAY); } + else + { + std::lock_guard<std::mutex> lock(ClientWebSocketsMutex); + LOG_TRC("Capturing Client WS for [" << id << "]"); + ClientWebSockets.push_back(ws); + } + } + catch (const std::exception& exc) + { + LOG_WRN("Exception while closing socket for session [" << id << + "] of docKey [" << docKey << "]: " << exc.what()); } } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits