summaryrefslogtreecommitdiffstats
path: root/lib/waiter
diff options
context:
space:
mode:
authorJeremy Kerr <jk@ozlabs.org>2013-06-01 20:07:40 +1000
committerJeremy Kerr <jk@ozlabs.org>2013-08-16 14:41:08 +0800
commitf6d419d22a4c69af185201b30f78b5a88da51219 (patch)
treeaa7a7c65e6841cbe4bc3f0602c08dd3bcba9aea5 /lib/waiter
parent7f4057edddbcb1b18293ebb96475ed37551edc73 (diff)
downloadpetitboot-f6d419d22a4c69af185201b30f78b5a88da51219.zip
petitboot-f6d419d22a4c69af185201b30f78b5a88da51219.tar.gz
lib/waiter: merge time & io waiter init loops
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Diffstat (limited to 'lib/waiter')
-rw-r--r--lib/waiter/waiter.c46
1 files changed, 22 insertions, 24 deletions
diff --git a/lib/waiter/waiter.c b/lib/waiter/waiter.c
index 1d9a7d8..b36c1af 100644
--- a/lib/waiter/waiter.c
+++ b/lib/waiter/waiter.c
@@ -176,34 +176,32 @@ static void update_waiters(struct waitset *set)
set->n_time_waiters = n_time;
}
- /* IO waiters: copy to io_waiters, populate pollfds */
- for (i = i_io = 0; i < set->n_waiters; i++) {
- struct waiter *waiter = set->waiters[i];
-
- if (waiter->type != WAITER_IO)
- continue;
-
- set->pollfds[i_io].fd = waiter->io.fd;
- set->pollfds[i_io].events = waiter->io.events;
- set->io_waiters[i_io] = waiter;
- i_io++;
- }
+ i_io = 0;
+ i_time = 0;
- /* time waiters: copy to time_waiters, calculate next expiry */
timerclear(&set->next_timeout);
- for (i = i_time = 0; i < set->n_waiters; i++) {
- struct waiter *waiter = set->waiters[i];
-
- if (waiter->type != WAITER_TIME)
- continue;
- if (!timerisset(&set->next_timeout) ||
- timercmp(&waiter->timeout,
- &set->next_timeout, <))
- set->next_timeout = waiter->timeout;
+ for (i = 0; i < set->n_waiters; i++) {
+ struct waiter *waiter = set->waiters[i];
- set->time_waiters[i_time] = waiter;
- i_time++;
+ /* IO waiters: copy to io_waiters, populate pollfds */
+ if (waiter->type == WAITER_IO) {
+ set->pollfds[i_io].fd = waiter->io.fd;
+ set->pollfds[i_io].events = waiter->io.events;
+ set->io_waiters[i_io] = waiter;
+ i_io++;
+ }
+
+ /* time waiters: copy to time_waiters, calculate next expiry */
+ if (waiter->type == WAITER_TIME) {
+ if (!timerisset(&set->next_timeout) ||
+ timercmp(&waiter->timeout,
+ &set->next_timeout, <))
+ set->next_timeout = waiter->timeout;
+
+ set->time_waiters[i_time] = waiter;
+ i_time++;
+ }
}
}
OpenPOWER on IntegriCloud