From 5ab36719f1c100afe483c58d7fcb15f1fa231d2a Mon Sep 17 00:00:00 2001 From: "Nicholas J. Kain" Date: Fri, 25 Dec 2015 02:44:54 -0500 Subject: [PATCH] If a fd closes unexpectedly in epoll, print error and exit with failure. Before the exit code would be success and no error message would print, and it required a bit of control flow tracing to determine what would actually happen. No direct functional change (unless the supervising process cares about the return code of ndhc on exit). --- src/ndhc.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/ndhc.c b/src/ndhc.c index bee0b8e..56f29f0 100644 --- a/src/ndhc.c +++ b/src/ndhc.c @@ -306,20 +306,20 @@ static void do_ndhc_work(void) int fd = events[i].data.fd; if (fd == cs.signalFd) { if (!(events[i].events & EPOLLIN)) - return; + suicide("signalfd closed unexpectedly"); sev_signal = signal_dispatch(); } else if (fd == cs.listenFd) { if (!(events[i].events & EPOLLIN)) - return; + suicide("listenfd closed unexpectedly"); sev_dhcp = dhcp_packet_get(&cs, &dhcp_packet, &dhcp_msgtype, &dhcp_srcaddr); } else if (fd == cs.arpFd) { if (!(events[i].events & EPOLLIN)) - return; + suicide("arpfd closed unexpectedly"); sev_arp = arp_packet_get(&cs); } else if (fd == cs.nlFd) { if (!(events[i].events & EPOLLIN)) - return; + suicide("nlfd closed unexpectedly"); sev_nl = nl_event_get(&cs); } else if (fd == ifchStream[0]) { if (events[i].events & (EPOLLHUP|EPOLLERR|EPOLLRDHUP)) @@ -329,7 +329,7 @@ static void do_ndhc_work(void) exit(EXIT_FAILURE); } else if (fd == cs.rfkillFd && client_config.enable_rfkill) { if (!(events[i].events & EPOLLIN)) - return; + suicide("rfkillfd closed unexpectedly"); sev_rfk = rfkill_get(&cs, 1, client_config.rfkillIdx); } else suicide("epoll_wait: unknown fd");