From f8607d7950013d26b33be022bd4d06acb5807cd0 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 21 Oct 2014 20:00:56 +0100 Subject: Nicer exception when we fail to listen for remote encode servers because some other DCP-o-matic is already at it (backport from 2.0). --- src/lib/server_finder.cc | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/lib') diff --git a/src/lib/server_finder.cc b/src/lib/server_finder.cc index a082f3bab..f034f46f6 100644 --- a/src/lib/server_finder.cc +++ b/src/lib/server_finder.cc @@ -26,6 +26,8 @@ #include "cross.h" #include "ui_signaller.h" +#include "i18n.h" + using std::string; using std::list; using std::vector; @@ -105,11 +107,16 @@ try using namespace boost::asio::ip; boost::asio::io_service io_service; - tcp::acceptor acceptor (io_service, tcp::endpoint (tcp::v4(), Config::instance()->server_port_base() + 1)); + boost::scoped_ptr acceptor; + try { + acceptor.reset (new tcp::acceptor (io_service, tcp::endpoint (tcp::v4(), Config::instance()->server_port_base() + 1))); + } catch (...) { + boost::throw_exception (NetworkError (_("Could not listen for remote encode servers. Perhaps another instance of DCP-o-matic is running."))); + } while (true) { tcp::socket socket (io_service); - acceptor.accept (socket); + acceptor->accept (socket); /* XXX: these reads should have timeouts, otherwise we will stop finding servers if one dies during this conversation -- cgit v1.2.3