From 0ad8007aacd88b4525c9ef8667c1ea2c0001ec27 Mon Sep 17 00:00:00 2001 From: Martin Lund Date: Sun, 12 Oct 2014 18:33:53 +0200 Subject: [PATCH] Eliminated first time connect delay Rearranged timeout handling so that the first time connect delay is eliminated. --- src/tty.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/tty.c b/src/tty.c index d9a5907..52d2541 100644 --- a/src/tty.c +++ b/src/tty.c @@ -52,7 +52,11 @@ void wait_for_tty_device(void) /* Loop until device pops up */ while (true) { - /* Wait up to 1 seconds */ + /* Test for device file */ + if (stat(option.tty_device, &status) == 0) + return; + + /* Wait up to 1 second */ tv.tv_sec = 1; tv.tv_usec = 0; @@ -73,13 +77,6 @@ void wait_for_tty_device(void) c_stdin[1] = c_stdin[0]; if ((c_stdin[1] == KEY_Q) && (c_stdin[2] == KEY_CTRL_G)) exit(EXIT_SUCCESS); - } else - { - /* Timeout */ - - /* Test for device file */ - if (stat(option.tty_device, &status) == 0) - return; } } }