From 69cf41f1b1fa8231c26f038adcc4a541990babaa Mon Sep 17 00:00:00 2001 From: "Nicholas J. Kain" Date: Wed, 18 Feb 2015 05:36:13 -0500 Subject: [PATCH] Only process one epoll event at a time. If ndhc were a high-performance program that handled lots of events, this change would harm performance. But it is not, and it implicitly believes that events come in one at a time. Processing batches would make it harder to assure correctness while also never allocating memory at runtime. The previous structure was fine when everything was handled immediately by callbacks, but it isn't now. --- src/ndhc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/ndhc.c b/src/ndhc.c index 83819b0..f33167e 100644 --- a/src/ndhc.c +++ b/src/ndhc.c @@ -263,14 +263,13 @@ static void fail_if_state_dir_dne(void) suicide("state_dir path '%s' does not specify a directory", state_dir); } -#define NDHC_NUM_EP_FDS 7 static void do_ndhc_work(void) { static bool rfkill_set; // Is the rfkill switch set? static bool rfkill_nl_state_changed; // iface state changed during rfkill static int rfkill_nl_state; // current iface state during rfkill struct dhcpmsg dhcp_packet; - struct epoll_event events[NDHC_NUM_EP_FDS]; + struct epoll_event events[1]; long long nowts; int timeout;