From a1a38e8aba0970729979f9dc0b3af72bd7b56e61 Mon Sep 17 00:00:00 2001 From: Alex Smith Date: Mon, 30 Jul 2012 21:38:47 +0100 Subject: [PATCH] Retry a few times if opening keyboard fails in consoled. I'm using consoled at the moment without input_server having been run, so when it starts the input drivers will not have been loaded. Have to retry a few times with delays so that the input devices have a chance to appear. --- src/bin/consoled/consoled.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/bin/consoled/consoled.cpp b/src/bin/consoled/consoled.cpp index 3a1497fed9..1b38c04151 100644 --- a/src/bin/consoled/consoled.cpp +++ b/src/bin/consoled/consoled.cpp @@ -223,9 +223,18 @@ stop_keyboards(struct console* con) static struct keyboard* open_keyboards(int target, const char* start, struct keyboard* previous) { - DIR* dir = opendir(start); - if (dir == NULL) - return NULL; + // Wait for the directory to appear, if we're loaded early in boot + // it may take a while for it to appear while the drivers load. + DIR* dir; + int32 tries = 0; + while (true) { + dir = opendir(start); + if (dir != NULL) + break; + if(++tries == 10) + return NULL; + sleep(1); + } struct keyboard* keyboard = previous;