summaryrefslogtreecommitdiffstats
path: root/ui/ncurses/nc-cui.c
diff options
context:
space:
mode:
authorJeremy Kerr <jk@ozlabs.org>2013-04-10 12:19:13 +1000
committerGeoff Levand <geoff@infradead.org>2013-04-10 10:49:20 -0700
commit37428306a270088bfcb1f94362a0fe5b7a5a888e (patch)
tree5d1aeca3eca44b68a8f8939e3bea44709a953aa9 /ui/ncurses/nc-cui.c
parentee86a0bd989511319adf3467b41b5b2e1f486aa6 (diff)
downloadtalos-petitboot-37428306a270088bfcb1f94362a0fe5b7a5a888e.tar.gz
talos-petitboot-37428306a270088bfcb1f94362a0fe5b7a5a888e.zip
waiter: Don't rely on global variables to keep waiter state
Rather than defining the set of waiters (and pollfds) in waiter.c, add a struct waitset to contain these. A waitset is created with waitset_create, which is passed to the waiter_* functions. Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Geoff Levand <geoff@infradead.org>
Diffstat (limited to 'ui/ncurses/nc-cui.c')
-rw-r--r--ui/ncurses/nc-cui.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/ui/ncurses/nc-cui.c b/ui/ncurses/nc-cui.c
index b9d8d79..a909b82 100644
--- a/ui/ncurses/nc-cui.c
+++ b/ui/ncurses/nc-cui.c
@@ -553,6 +553,7 @@ struct cui *cui_init(void* platform_info,
cui->on_kexec = on_kexec;
cui->timer.handle_timeout = cui_handle_timeout;
cui->dry_run = dry_run;
+ cui->waitset = waitset_create(cui);
/* Loop here for scripts that just started the server. */
@@ -595,18 +596,19 @@ retry_start:
atexit(nc_atexit);
nc_start();
- waiter_register(discover_client_get_fd(client), WAIT_IN,
- cui_client_process_socket, client);
+ waiter_register(cui->waitset, discover_client_get_fd(client), WAIT_IN,
+ cui_client_process_socket, client);
- waiter_register(STDIN_FILENO, WAIT_IN, cui_process_key, cui);
+ waiter_register(cui->waitset, STDIN_FILENO, WAIT_IN,
+ cui_process_key, cui);
if (js_map) {
cui->pjs = pjs_init(cui, js_map);
if (cui->pjs)
- waiter_register(pjs_get_fd(cui->pjs), WAIT_IN,
- cui_process_js, cui);
+ waiter_register(cui->waitset, pjs_get_fd(cui->pjs),
+ WAIT_IN, cui_process_js, cui);
}
return cui;
@@ -638,7 +640,7 @@ int cui_run(struct cui *cui, struct pmenu *main, unsigned int default_item)
cui->current->post(cui->current);
while (1) {
- int result = waiter_poll();
+ int result = waiter_poll(cui->waitset);
if (result < 0 && errno != EINTR) {
pb_log("%s: poll: %s\n", __func__, strerror(errno));
OpenPOWER on IntegriCloud