From: Marcin Siodelski Date: Fri, 13 Mar 2015 10:31:34 +0000 (+0100) Subject: [3715] Use foreach to iterate over IfaceMgr callbacks. X-Git-Tag: trac3764_base~10^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=29cc4209a30b1656c7e8c19c2f45aa2b90087169;p=thirdparty%2Fkea.git [3715] Use foreach to iterate over IfaceMgr callbacks. --- diff --git a/src/lib/dhcp/iface_mgr.cc b/src/lib/dhcp/iface_mgr.cc index f904cfce1a..a709bab875 100644 --- a/src/lib/dhcp/iface_mgr.cc +++ b/src/lib/dhcp/iface_mgr.cc @@ -292,13 +292,11 @@ IfaceMgr::isDirectResponseSupported() const { void IfaceMgr::addExternalSocket(int socketfd, SocketCallback callback) { - for (SocketCallbackInfoContainer::iterator s = callbacks_.begin(); - s != callbacks_.end(); ++s) { - + BOOST_FOREACH(SocketCallbackInfo s, callbacks_) { // There's such a socket description there already. // Update the callback and we're done - if (s->socket_ == socketfd) { - s->callback_ = callback; + if (s.socket_ == socketfd) { + s.callback_ = callback; return; } } @@ -909,11 +907,10 @@ IfaceMgr::receive4(uint32_t timeout_sec, uint32_t timeout_usec /* = 0 */) { // if there are any callbacks for external sockets registered... if (!callbacks_.empty()) { - for (SocketCallbackInfoContainer::const_iterator s = callbacks_.begin(); - s != callbacks_.end(); ++s) { - FD_SET(s->socket_, &sockets); - if (maxfd < s->socket_) { - maxfd = s->socket_; + BOOST_FOREACH(SocketCallbackInfo s, callbacks_) { + FD_SET(s.socket_, &sockets); + if (maxfd < s.socket_) { + maxfd = s.socket_; } } } @@ -944,9 +941,8 @@ IfaceMgr::receive4(uint32_t timeout_sec, uint32_t timeout_usec /* = 0 */) { } // Let's find out which socket has the data - for (SocketCallbackInfoContainer::iterator s = callbacks_.begin(); - s != callbacks_.end(); ++s) { - if (!FD_ISSET(s->socket_, &sockets)) { + BOOST_FOREACH(SocketCallbackInfo s, callbacks_) { + if (!FD_ISSET(s.socket_, &sockets)) { continue; } @@ -955,8 +951,8 @@ IfaceMgr::receive4(uint32_t timeout_sec, uint32_t timeout_usec /* = 0 */) { // Calling the external socket's callback provides its service // layer access without integrating any specific features // in IfaceMgr - if (s->callback_) { - s->callback_(); + if (s.callback_) { + s.callback_(); } return (Pkt4Ptr()); @@ -1017,13 +1013,11 @@ Pkt6Ptr IfaceMgr::receive6(uint32_t timeout_sec, uint32_t timeout_usec /* = 0 */ // if there are any callbacks for external sockets registered... if (!callbacks_.empty()) { - for (SocketCallbackInfoContainer::const_iterator s = callbacks_.begin(); - s != callbacks_.end(); ++s) { - + BOOST_FOREACH(SocketCallbackInfo s, callbacks_) { // Add it to the set as well - FD_SET(s->socket_, &sockets); - if (maxfd < s->socket_) { - maxfd = s->socket_; + FD_SET(s.socket_, &sockets); + if (maxfd < s.socket_) { + maxfd = s.socket_; } } } @@ -1054,9 +1048,8 @@ Pkt6Ptr IfaceMgr::receive6(uint32_t timeout_sec, uint32_t timeout_usec /* = 0 */ } // Let's find out which socket has the data - for (SocketCallbackInfoContainer::iterator s = callbacks_.begin(); - s != callbacks_.end(); ++s) { - if (!FD_ISSET(s->socket_, &sockets)) { + BOOST_FOREACH(SocketCallbackInfo s, callbacks_) { + if (!FD_ISSET(s.socket_, &sockets)) { continue; } @@ -1065,8 +1058,8 @@ Pkt6Ptr IfaceMgr::receive6(uint32_t timeout_sec, uint32_t timeout_usec /* = 0 */ // Calling the external socket's callback provides its service // layer access without integrating any specific features // in IfaceMgr - if (s->callback_) { - s->callback_(); + if (s.callback_) { + s.callback_(); } return (Pkt6Ptr());