if (!candidate) {
isc_throw(SocketFDError, "received data over unknown socket");
}
+
// Assuming that packet filter is not null, because its modifier checks it.
return (packet_filter6_->receive(*candidate));
}
ex_sock = s;
break;
}
- } else {
-
}
}
}
for (;;) {
try {
- // Check the watch socket.
- if (dhcp_receiver_->shouldTerminate()) {
- return;
- }
-
- // zero out the errno to be safe.
- errno = 0;
+ // Check the watch socket.
+ if (dhcp_receiver_->shouldTerminate()) {
+ return;
+ }
- // Select with null timeouts to wait indefinitely an event
- int result = receiver_fd_event_handler_->waitEvent(0, 0, false);
+ // zero out the errno to be safe.
+ errno = 0;
- // Re-check the watch socket.
- if (dhcp_receiver_->shouldTerminate()) {
- return;
- }
+ // Select with null timeouts to wait indefinitely an event
+ int result = receiver_fd_event_handler_->waitEvent(0, 0, false);
- if (result == 0) {
- // nothing received?
- continue;
- } else if (result < 0) {
- // This thread should not get signals?
- if (errno != EINTR) {
- // Signal the error to receive4.
- dhcp_receiver_->setError(strerror(errno));
- // We need to sleep in case of the error condition to
- // prevent the thread from tight looping when result
- // gets negative.
- sleep(1);
+ // Re-check the watch socket.
+ if (dhcp_receiver_->shouldTerminate()) {
+ return;
}
- continue;
- }
- // Let's find out which interface/socket has data.
- for (const IfacePtr& iface : ifaces_) {
- for (const SocketInfo& s : iface->getSockets()) {
- if (!receiver_fd_event_handler_->readReady(s.sockfd_) &&
- !receiver_fd_event_handler_->hasError(s.sockfd_)) {
- continue;
- }
- if (receiver_fd_event_handler_->hasError(s.sockfd_)) {
- handleIfaceSocketError(s);
+ if (result == 0) {
+ // nothing received?
+ continue;
+ } else if (result < 0) {
+ // This thread should not get signals?
+ if (errno != EINTR) {
+ // Signal the error to receive4.
+ dhcp_receiver_->setError(strerror(errno));
+ // We need to sleep in case of the error condition to
+ // prevent the thread from tight looping when result
+ // gets negative.
+ sleep(1);
}
- receiveDHCP4Packet(*iface, s);
- // Can take time so check one more time the watch socket.
- if (dhcp_receiver_->shouldTerminate()) {
- return;
+ continue;
+ }
+
+ // Let's find out which interface/socket has data.
+ for (const IfacePtr& iface : ifaces_) {
+ for (const SocketInfo& s : iface->getSockets()) {
+ if (!receiver_fd_event_handler_->readReady(s.sockfd_) &&
+ !receiver_fd_event_handler_->hasError(s.sockfd_)) {
+ continue;
+ }
+ if (receiver_fd_event_handler_->hasError(s.sockfd_)) {
+ handleIfaceSocketError(s);
+ }
+ receiveDHCP4Packet(*iface, s);
+ // Can take time so check one more time the watch socket.
+ if (dhcp_receiver_->shouldTerminate()) {
+ return;
+ }
}
}
- }
} catch (const std::exception& ex) {
dhcp_receiver_->setError(string(ex.what()) + " error: " + strerror(errno));
} catch (...) {
for (;;) {
try {
- // Check the watch socket.
- if (dhcp_receiver_->shouldTerminate()) {
- return;
- }
+ // Check the watch socket.
+ if (dhcp_receiver_->shouldTerminate()) {
+ return;
+ }
- // zero out the errno to be safe.
- errno = 0;
+ // zero out the errno to be safe.
+ errno = 0;
- // Select with null timeouts to wait indefinitely an event
- int result = receiver_fd_event_handler_->waitEvent(0, 0, false);
+ // Select with null timeouts to wait indefinitely an event
+ int result = receiver_fd_event_handler_->waitEvent(0, 0, false);
- // Re-check the watch socket.
- if (dhcp_receiver_->shouldTerminate()) {
- return;
- }
-
- if (result == 0) {
- // nothing received?
- continue;
- } else if (result < 0) {
- // This thread should not get signals?
- if (errno != EINTR) {
- // Signal the error to receive6.
- dhcp_receiver_->setError(strerror(errno));
- // We need to sleep in case of the error condition to
- // prevent the thread from tight looping when result
- // gets negative.
- sleep(1);
+ // Re-check the watch socket.
+ if (dhcp_receiver_->shouldTerminate()) {
+ return;
}
- continue;
- }
- // Let's find out which interface/socket has data.
- for (const IfacePtr& iface : ifaces_) {
- for (const SocketInfo& s : iface->getSockets()) {
- if (!receiver_fd_event_handler_->readReady(s.sockfd_) &&
- !receiver_fd_event_handler_->hasError(s.sockfd_)) {
- continue;
- }
- if (receiver_fd_event_handler_->hasError(s.sockfd_)) {
- handleIfaceSocketError(s);
+ if (result == 0) {
+ // nothing received?
+ continue;
+ } else if (result < 0) {
+ // This thread should not get signals?
+ if (errno != EINTR) {
+ // Signal the error to receive6.
+ dhcp_receiver_->setError(strerror(errno));
+ // We need to sleep in case of the error condition to
+ // prevent the thread from tight looping when result
+ // gets negative.
+ sleep(1);
}
- receiveDHCP6Packet(s);
- // Can take time so check one more time the watch socket.
- if (dhcp_receiver_->shouldTerminate()) {
- return;
+ continue;
+ }
+
+ // Let's find out which interface/socket has data.
+ for (const IfacePtr& iface : ifaces_) {
+ for (const SocketInfo& s : iface->getSockets()) {
+ if (!receiver_fd_event_handler_->readReady(s.sockfd_) &&
+ !receiver_fd_event_handler_->hasError(s.sockfd_)) {
+ continue;
+ }
+ if (receiver_fd_event_handler_->hasError(s.sockfd_)) {
+ handleIfaceSocketError(s);
+ }
+ receiveDHCP6Packet(s);
+ // Can take time so check one more time the watch socket.
+ if (dhcp_receiver_->shouldTerminate()) {
+ return;
+ }
}
}
- }
} catch (const std::exception& ex) {
dhcp_receiver_->setError(string(ex.what()) + " error: " + strerror(errno));
} catch (...) {