From 103b8d9228a11fb6f17c92bb047ec4730144cd18 Mon Sep 17 00:00:00 2001 From: Jan Moringen Date: Wed, 30 Apr 2014 09:41:28 +0200 Subject: [PATCH 1/2] Do not abort on failed shutdown in src/rsb/transport/socket/BusConnection.cpp fixes #1846 Apparently, an exception can be thrown during socket shutdown when the remote peer requests a shutdown and the local side is not quick enough with its shutdown. This seems like incorrect behavior of the remote peer but has to be handled anyway since e.g. a crash of the remote program would have an identical effect. * src/rsb/transport/socket/BusConnection.cpp (header): updated copyright (BusConnection::handleReadLength): catch exceptions thrown by shutdown, print a warning but ignore otherwise --- src/rsb/transport/socket/BusConnection.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/rsb/transport/socket/BusConnection.cpp b/src/rsb/transport/socket/BusConnection.cpp index bdb99fe..c2c8d86 100644 --- a/src/rsb/transport/socket/BusConnection.cpp +++ b/src/rsb/transport/socket/BusConnection.cpp @@ -2,7 +2,7 @@ * * This file is part of the RSB project * - * Copyright (C) 2011, 2012 Jan Moringen + * Copyright (C) 2011, 2012, 2014 Jan Moringen * * This file may be licensed under the terms of the * GNU Lesser General Public License Version 3 (the ``LGPL''), @@ -180,7 +180,11 @@ void BusConnection::handleReadLength(const boost::system::error_code& error, if (error == boost::asio::error::eof) { RSCDEBUG(logger, "Received eof"); if (!this->activeShutdown) { - shutdown(); + try { + shutdown(); + } catch (const std::exception& e) { + RSCWARN(this->logger, "Failed to shut down socket: " << e.what()); + } } performSafeCleanup("handleReadLength[eof]"); return; -- 1.7.9.5