From d384a9cbc278756523ae59dd12131df78859a518 Mon Sep 17 00:00:00 2001 From: David Teigland Date: Mar 10 2020 17:28:19 +0000 Subject: sanlock: clean up poll event checks for efd Never look at clients array when checking efd. (No evidence of any problems from this.) --- diff --git a/src/main.c b/src/main.c index d2e8c9a..5ed125b 100644 --- a/src/main.c +++ b/src/main.c @@ -763,13 +763,27 @@ static int main_loop(void) /* not sure */ } for (i = 0; i <= client_maxi + 1; i++) { - if (pollfd[i].fd == efd && pollfd[i].revents & POLLIN) { - /* a client_resume completed */ - eventfd_read(efd, &ebuf); + /* + * This index for efd has no client array entry. Its + * only purpose is to wake up this poll loop in which + * case we just clear any data and continue looking + * for other client entries that need processing. + */ + if (pollfd[i].fd == efd) { + if (pollfd[i].revents & POLLIN) { + eventfd_read(efd, &ebuf); + } continue; } + + /* + * FIXME? client_maxi is never reduced so over time we + * end up checking and skipping some number of unused + * client entries here which seems inefficient. + */ if (client[i].fd < 0) continue; + if (pollfd[i].revents & POLLIN) { workfn = client[i].workfn; if (workfn)