From: Michal 'vorner' Vaner Date: Wed, 4 Jan 2012 10:10:19 +0000 (+0100) Subject: [805] Some exception handling X-Git-Tag: trac2351_base~304^2~16^2~10 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5e04e03abdb6960f58127868ae91d596f18edd30;p=thirdparty%2Fkea.git [805] Some exception handling Catch on the closing bracket, include little bit more in the try. --- diff --git a/src/lib/asiodns/tcp_server.cc b/src/lib/asiodns/tcp_server.cc index 63b941d545..b351f71ee9 100644 --- a/src/lib/asiodns/tcp_server.cc +++ b/src/lib/asiodns/tcp_server.cc @@ -83,14 +83,13 @@ TCPServer::TCPServer(io_service& io_service, int fd, int af, } LOG_DEBUG(logger, DBGLVL_TRACE_BASIC, ASIODNS_FD_ADD_TCP).arg(fd); - acceptor_.reset(new tcp::acceptor(io_service)); try { + acceptor_.reset(new tcp::acceptor(io_service)); acceptor_->assign(af == AF_INET6 ? tcp::v6() : tcp::v4(), fd); acceptor_->listen(); - } - // Whatever the thing throws, it is something from ASIO and we convert - // it - catch (const std::exception& exception) { + } catch (const std::exception& exception) { + // Whatever the thing throws, it is something from ASIO and we convert + // it isc_throw(IOError, exception.what()); } } diff --git a/src/lib/asiodns/udp_server.cc b/src/lib/asiodns/udp_server.cc index 9618aa746d..001fdd5989 100644 --- a/src/lib/asiodns/udp_server.cc +++ b/src/lib/asiodns/udp_server.cc @@ -86,16 +86,12 @@ struct UDPServer::Data { "or AF_INET6, not " << af); } LOG_DEBUG(logger, DBGLVL_TRACE_BASIC, ASIODNS_FD_ADD_UDP).arg(fd); - // We must use different instantiations for v4 and v6; - // otherwise ASIO will bind to both - udp proto = af == AF_INET6 ? udp::v6() : udp::v4(); - socket_.reset(new udp::socket(io_service)); try { - socket_->assign(proto, fd); - } - // Whatever the thing throws, it is something from ASIO and we convert - // it - catch (const std::exception& exception) { + socket_.reset(new udp::socket(io_service)); + socket_->assign(AF_INET6 ? udp::v6() : udp::v4(), fd); + } catch (const std::exception& exception) { + // Whatever the thing throws, it is something from ASIO and we convert + // it isc_throw(IOError, exception.what()); } }