#include <senf/Utils/senfassert.hh>
#include <senf/Utils/membind.hh>
#include <senf/Utils/Logger/SenfLog.hh>
+#include <senf/Version.hh>
#include "LineEditor.hh"
#include "ScopedDirectory.hh"
#include "Sysdir.hh"
+#include "SysInfo.hh"
#include "ParsedCommand.hh"
//#include "Server.mpp"
#define prefix_
///////////////////////////////cc.p////////////////////////////////////////
+namespace {
+ senf::console::SysInfo::Proxy addSysInfo (
+ "SENF: The Simple and Extensible Network Framework\n"
+ " © 2006-2010 Fraunhofer Institute for Open Communication Systems, Network Research\n"
+ " Contact: senf-dev@lists.berlios.de\n"
+ " Version: " SENF_LIB_VERSION " Revision number: " SENF_REVISION "\n", 0);
+}
///////////////////////////////////////////////////////////////////////////
// senf::console::detail::NonBlockingSocketSink
client_.write(data);
}
}
- catch (SystemException & ex) {
- ;
- }
+ catch (...) {}
return n;
}
log << client.handle().peer();
}
catch (senf::SystemException ex) {
- log << "(unknown)";
+ log << "(dead socket)";
}
}));
// THIS DELETES THE CLIENT INSTANCE !!
prompt += " ";
stream() << std::flush;
- handle().write(prompt);
promptLen_ = prompt.size();
promptActive_ = true;
+ v_write(prompt);
}
prefix_ void senf::console::detail::DumbClientReader::v_disablePrompt()
prefix_ void senf::console::detail::DumbClientReader::v_write(std::string const & data)
{
- handle().write(data);
+ try {
+ handle().write(data);
+ }
+ catch (senf::ExceptionMixin & ex) {
+ SENF_LOG(("unexpected failure writing to socket:" << ex.message()));
+ try { handle().facet<senf::TCPSocketProtocol>().shutdown(senf::TCPSocketProtocol::ShutRD); }
+ catch (...) {}
+ }
+ catch (std::exception & ex) {
+ SENF_LOG(("unexpected failure writing to socket:" << ex.what()));
+ try { handle().facet<senf::TCPSocketProtocol>().shutdown(senf::TCPSocketProtocol::ShutRD); }
+ catch (...) {}
+ }
+ catch (...) {
+ SENF_LOG(("unexpected failure writing to socket: unknown exception"));
+ try { handle().facet<senf::TCPSocketProtocol>().shutdown(senf::TCPSocketProtocol::ShutRD); }
+ catch (...) {}
+ }
}
prefix_ unsigned senf::console::detail::DumbClientReader::v_width()
prefix_ void senf::console::detail::NoninteractiveClientReader::v_write(std::string const & data)
{
- handle().write(data);
+ try {
+ handle().write(data);
+ }
+ catch (senf::ExceptionMixin & ex) {
+ SENF_LOG(("unexpected failure writing to socket:" << ex.message()));
+ try { handle().facet<senf::TCPSocketProtocol>().shutdown(senf::TCPSocketProtocol::ShutRD); }
+ catch (...) {}
+ }
+ catch (std::exception & ex) {
+ SENF_LOG(("unexpected failure writing to socket:" << ex.what()));
+ try { handle().facet<senf::TCPSocketProtocol>().shutdown(senf::TCPSocketProtocol::ShutRD); }
+ catch (...) {}
+ }
+ catch (...) {
+ SENF_LOG(("unexpected failure writing to socket: unknown exception"));
+ try { handle().facet<senf::TCPSocketProtocol>().shutdown(senf::TCPSocketProtocol::ShutRD); }
+ catch (...) {}
+ }
}
prefix_ unsigned senf::console::detail::NoninteractiveClientReader::v_width()
// handled gracefully by the ClientReader. We cannot call stop() here, since we are called
// from the client reader callback and that will continue executing after stop() has been
// called. stop() however will delete *this instance ... BANG ...
- handle_.facet<senf::TCPSocketProtocol>().shutdown(senf::TCPSocketProtocol::ShutRD);
+ try { handle_.facet<senf::TCPSocketProtocol>().shutdown(senf::TCPSocketProtocol::ShutRD); }
+ catch (...) {}
}
catch (std::exception & ex) {
std::string msg (ex.what());