From: Francis Dupont Date: Tue, 16 Jun 2020 12:02:01 +0000 (+0200) Subject: [#1234] Added a return for external sockets without handlers X-Git-Tag: Kea-1.7.9~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d8387f8f7d96d6923452319626738194cc799cd9;p=thirdparty%2Fkea.git [#1234] Added a return for external sockets without handlers --- diff --git a/src/lib/dhcp/iface_mgr.cc b/src/lib/dhcp/iface_mgr.cc index 7dfad76df7..e5fee84ffc 100644 --- a/src/lib/dhcp/iface_mgr.cc +++ b/src/lib/dhcp/iface_mgr.cc @@ -1091,12 +1091,14 @@ Pkt4Ptr IfaceMgr::receive4Indirect(uint32_t timeout_sec, uint32_t timeout_usec / // Let's find out which external socket has the data SocketCallbackInfo ex_sock; + bool found = false; { std::lock_guard lock(callbacks_mutex_); BOOST_FOREACH(SocketCallbackInfo s, callbacks_) { if (!FD_ISSET(s.socket_, &sockets)) { continue; } + found = true; // something received over external socket if (s.callback_) { @@ -1113,7 +1115,8 @@ Pkt4Ptr IfaceMgr::receive4Indirect(uint32_t timeout_sec, uint32_t timeout_usec / // layer access without integrating any specific features // in IfaceMgr ex_sock.callback_(ex_sock.socket_); - + } + if (found) { return (Pkt4Ptr()); } } @@ -1199,12 +1202,14 @@ Pkt4Ptr IfaceMgr::receive4Direct(uint32_t timeout_sec, uint32_t timeout_usec /* // Let's find out which socket has the data SocketCallbackInfo ex_sock; + bool found = false; { std::lock_guard lock(callbacks_mutex_); BOOST_FOREACH(SocketCallbackInfo s, callbacks_) { if (!FD_ISSET(s.socket_, &sockets)) { continue; } + found = true; // something received over external socket if (s.callback_) { @@ -1221,7 +1226,8 @@ Pkt4Ptr IfaceMgr::receive4Direct(uint32_t timeout_sec, uint32_t timeout_usec /* // layer access without integrating any specific features // in IfaceMgr ex_sock.callback_(ex_sock.socket_); - + } + if (found) { return (Pkt4Ptr()); } @@ -1341,12 +1347,14 @@ IfaceMgr::receive6Direct(uint32_t timeout_sec, uint32_t timeout_usec /* = 0 */ ) // Let's find out which socket has the data SocketCallbackInfo ex_sock; + bool found = false; { std::lock_guard lock(callbacks_mutex_); BOOST_FOREACH(SocketCallbackInfo s, callbacks_) { if (!FD_ISSET(s.socket_, &sockets)) { continue; } + found = true; // something received over external socket if (s.callback_) { @@ -1363,7 +1371,8 @@ IfaceMgr::receive6Direct(uint32_t timeout_sec, uint32_t timeout_usec /* = 0 */ ) // layer access without integrating any specific features // in IfaceMgr ex_sock.callback_(ex_sock.socket_); - + } + if (found) { return (Pkt6Ptr()); } @@ -1471,12 +1480,14 @@ IfaceMgr::receive6Indirect(uint32_t timeout_sec, uint32_t timeout_usec /* = 0 */ // Let's find out which external socket has the data SocketCallbackInfo ex_sock; + bool found = false; { std::lock_guard lock(callbacks_mutex_); BOOST_FOREACH(SocketCallbackInfo s, callbacks_) { if (!FD_ISSET(s.socket_, &sockets)) { continue; } + found = true; // something received over external socket if (s.callback_) { @@ -1493,7 +1504,8 @@ IfaceMgr::receive6Indirect(uint32_t timeout_sec, uint32_t timeout_usec /* = 0 */ // layer access without integrating any specific features // in IfaceMgr ex_sock.callback_(ex_sock.socket_); - + } + if (found) { return (Pkt6Ptr()); } }