ui/ncurses: only cancel default boot on valid key events
authorJeremy Kerr <jk@ozlabs.org>
Tue, 22 Apr 2014 02:41:59 +0000 (10:41 +0800)
committerJeremy Kerr <jk@ozlabs.org>
Tue, 22 Apr 2014 02:44:09 +0000 (10:44 +0800)
We're seeing occasionaly failures to autoboot due to supirious key
events (getch() returing -1) on an IPMI console.

This change modifies the process_key logic to only abort the default if
we see a valid key event.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
ui/ncurses/nc-cui.c

index 5f5640975c2356b00d2d3a71a8585af5974ef54a..7200a81ae4bc5c5a87c5fe8437303751d5a3a033 100644 (file)
@@ -327,10 +327,6 @@ static int cui_process_key(void *arg)
 
        assert(cui->current);
 
-       if (!cui->has_input)
-               discover_client_cancel_default(cui->client);
-       cui->has_input = true;
-
        for (;;) {
                int c = getch();
 
@@ -339,6 +335,13 @@ static int cui_process_key(void *arg)
                if (c == ERR)
                        break;
 
+               if (!cui->has_input) {
+                       pb_log("UI input received (key = %d), aborting "
+                                       "default boot\n", c);
+                       discover_client_cancel_default(cui->client);
+                       cui->has_input = true;
+               }
+
                if (process_global_keys(cui, c))
                        continue;