From 4b06a77805ea3fd7bc0829d8096f87b341c77832 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 21 Oct 2014 19:59:16 +0100 Subject: [PATCH] Nicer exception when we fail to listen for remote encode servers because some other DCP-o-matic is already at it. --- src/lib/server_finder.cc | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/lib/server_finder.cc b/src/lib/server_finder.cc index 637103591..35ce9e1a1 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 -- 2.30.2