]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[805] Some exception handling
authorMichal 'vorner' Vaner <michal.vaner@nic.cz>
Wed, 4 Jan 2012 10:10:19 +0000 (11:10 +0100)
committerMichal 'vorner' Vaner <michal.vaner@nic.cz>
Wed, 4 Jan 2012 10:10:19 +0000 (11:10 +0100)
Catch on the closing bracket, include little bit more in the try.

src/lib/asiodns/tcp_server.cc
src/lib/asiodns/udp_server.cc

index 63b941d5455bdde35f4b2967ca511d58d42b8f72..b351f71ee91c88f4f1f272b4feb663cf0483a4b8 100644 (file)
@@ -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());
     }
 }
index 9618aa746ddc621bd14b26b2c93bc59a6a166fd3..001fdd59897af4264f3c176caea5a46112921f8a 100644 (file)
@@ -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());
         }
     }