commit 56cc828abf19143afb462eff14df6b6abf4bf9d3
parent 75495f8338752a80aad4bce172bd0ae240f9a2d1
Author: Jacob R. Edwards <jacobouno@protonmail.com>
Date: Tue, 20 Jul 2021 15:01:52 -0700
Fix aps_update resource waste
The variable containing the number of return events wouldn't be
used unless every client had an error. While not the cause of errors
it did waste resources.
Diffstat:
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/aps/aps.c b/aps/aps.c
@@ -141,12 +141,13 @@ aps_update(struct aps *aps)
int i;
int re;
- if ((re = poll(aps->pfds, LEN(aps->pfds), timeout)) == -1)
- return 1;
+ if ((re = poll(aps->pfds, LEN(aps->pfds), timeout)) <= 0)
+ return re;
for (i = 0; re > 0 && i < LEN(aps->pfds); ++i) {
- if (aps->pfds[i].revents && aps_handle(aps, i)) {
- aps_drop(aps, i);
+ if (aps->pfds[i].revents) {
+ if (aps_handle(aps, i))
+ aps_drop(aps, i);
--re;
}
}