From: g0dil Date: Wed, 15 Sep 2010 15:32:22 +0000 (+0000) Subject: Utils/Console: Fix console crash on socket write failure X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=ecb47e13433d59c79a74a4641a2e68648f142723;p=senf.git Utils/Console: Fix console crash on socket write failure git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1716 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/senf/Utils/Console/Server.cc b/senf/Utils/Console/Server.cc index 8eb41ac..40b4d80 100644 --- a/senf/Utils/Console/Server.cc +++ b/senf/Utils/Console/Server.cc @@ -173,7 +173,7 @@ prefix_ void senf::console::detail::DumbClientReader::showPrompt() prompt += " "; stream() << std::flush; - handle().write(prompt); + v_write(prompt); promptLen_ = prompt.size(); promptActive_ = true; } @@ -194,7 +194,17 @@ prefix_ void senf::console::detail::DumbClientReader::v_enablePrompt() prefix_ void senf::console::detail::DumbClientReader::v_write(std::string const & data) { - handle().write(data); + try { + handle().write(data); + } + catch (std::exception & ex) { + SENF_LOG(("unexpected failure writing to socket:" << ex.what())); + stopClient(); // SUICIDE + } + catch (...) { + SENF_LOG(("unexpected failure writing to socket: unknown exception")); + stopClient(); // SUICIDE + } } prefix_ unsigned senf::console::detail::DumbClientReader::v_width() @@ -222,7 +232,17 @@ prefix_ void senf::console::detail::NoninteractiveClientReader::v_enablePrompt() prefix_ void senf::console::detail::NoninteractiveClientReader::v_write(std::string const & data) { - handle().write(data); + try { + handle().write(data); + } + catch (std::exception & ex) { + SENF_LOG(("unexpected failure writing to socket:" << ex.what())); + stopClient(); // SUICIDE + } + catch (...) { + SENF_LOG(("unexpected failure writing to socket: unknown exception")); + stopClient(); // SUICIDE + } } prefix_ unsigned senf::console::detail::NoninteractiveClientReader::v_width() diff --git a/senf/Utils/Console/Server.ih b/senf/Utils/Console/Server.ih index 2e793be..fceb6c7 100644 --- a/senf/Utils/Console/Server.ih +++ b/senf/Utils/Console/Server.ih @@ -30,6 +30,7 @@ #include #include #include +#include ///////////////////////////////ih.p//////////////////////////////////////// @@ -93,6 +94,8 @@ namespace detail { class ClientReader { public: + SENF_LOG_CLASS_AREA(); + typedef ServerHandle::ClientHandle ClientHandle; virtual ~ClientReader() = 0;