]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[4551] Fixed
authorFrancis Dupont <fdupont@isc.org>
Wed, 17 Aug 2016 11:58:36 +0000 (13:58 +0200)
committerFrancis Dupont <fdupont@isc.org>
Wed, 17 Aug 2016 11:58:36 +0000 (13:58 +0200)
src/lib/dhcp/iface_mgr.cc
src/lib/dhcp/tests/iface_mgr_unittest.cc

index 70561ba3bc9e065a2411d99db1e6c53d1c691491..8afb0d60f11701f7b50ff7aa47fc2b66c5c9fb89 100644 (file)
@@ -887,7 +887,7 @@ IfaceMgr::receive4(uint32_t timeout_sec, uint32_t timeout_usec /* = 0 */) {
         isc_throw(BadValue, "fractional timeout must be shorter than"
                   " one million microseconds");
     }
-    const SocketInfo* candidate = 0;
+    boost::shared_ptr<SocketInfo> candidate;
     IfacePtr iface;
     fd_set sockets;
     int maxfd = 0;
@@ -972,7 +972,7 @@ IfaceMgr::receive4(uint32_t timeout_sec, uint32_t timeout_usec /* = 0 */) {
     BOOST_FOREACH(iface, ifaces_) {
         BOOST_FOREACH(SocketInfo s, iface->getSockets()) {
             if (FD_ISSET(s.sockfd_, &sockets)) {
-                candidate = &(s);
+                candidate.reset(new SocketInfo(s));
                 break;
             }
         }
@@ -997,7 +997,7 @@ Pkt6Ptr IfaceMgr::receive6(uint32_t timeout_sec, uint32_t timeout_usec /* = 0 */
                   " one million microseconds");
     }
 
-    const SocketInfo* candidate = 0;
+    boost::shared_ptr<SocketInfo> candidate;
     fd_set sockets;
     int maxfd = 0;
 
@@ -1082,7 +1082,7 @@ Pkt6Ptr IfaceMgr::receive6(uint32_t timeout_sec, uint32_t timeout_usec /* = 0 */
     BOOST_FOREACH(IfacePtr iface, ifaces_) {
         BOOST_FOREACH(SocketInfo s, iface->getSockets()) {
             if (FD_ISSET(s.sockfd_, &sockets)) {
-                candidate = &(s);
+                candidate.reset(new SocketInfo(s));
                 break;
             }
         }
index efd21df6a5a491d0d2bb0648e1a83420bf3499c6..5136a10ed3af006135ed050f9b8f6ce151bdf2d5 100644 (file)
@@ -2833,15 +2833,17 @@ TEST_F(IfaceMgrTest, unicastDuplicates) {
     NakedIfaceMgr ifacemgr;
 
     IfacePtr iface = ifacemgr.getIface(LOOPBACK);
-    if (iface) {
+    if (!iface) {
         cout << "Local loopback interface not found. Skipping test. " << endl;
         return;
     }
 
     // Tell the interface that it should bind to this global interface
+    // It is the first attempt so it should succeed
     EXPECT_NO_THROW(iface->addUnicast(IOAddress("2001:db8::1")));
 
     // Tell the interface that it should bind to this global interface
+    // It is the second attempt so it should fail
     EXPECT_THROW(iface->addUnicast(IOAddress("2001:db8::1")), BadValue);
 }