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.
This commit is contained in:
Alex Smith
2012-07-30 21:38:47 +01:00
parent 533f3bb494
commit a1a38e8aba
+12 -3
View File
@@ -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;