From 3ec9ac09464b1ea3e809f39753aac1ceb9913ee4 Mon Sep 17 00:00:00 2001 From: sobomax Date: Sat, 10 Jan 2004 13:09:21 +0000 Subject: Fix serious ugliness introduced in 1.61, which leads to long delay in boot sequence when machine is started without attached USB mouse. Only do repeated attempts to re-open device if the usb module has been actually loaded. Also fix broken logic in doing delays between open attempts - do delays between attempts, not after each attempt. Due to previous behaviour being very annoying for notebook owners this is a good 5.2 MFC candidate. MFC after: 2 days --- usr.sbin/moused/moused.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/usr.sbin/moused/moused.c b/usr.sbin/moused/moused.c index 0bca756..b08365f 100644 --- a/usr.sbin/moused/moused.c +++ b/usr.sbin/moused/moused.c @@ -756,8 +756,8 @@ main(int argc, char *argv[]) retry = 1; if (strncmp(rodent.portname, "/dev/ums", 8) == 0) { - usbmodule(); - retry = 5; + if (usbmodule() != 0) + retry = 5; } for (;;) { @@ -767,10 +767,11 @@ main(int argc, char *argv[]) signal(SIGQUIT, cleanup); signal(SIGTERM, cleanup); for (i = 0; i < retry; ++i) { + if (i > 0) + sleep(2); rodent.mfd = open(rodent.portname, O_RDWR | O_NONBLOCK); if (rodent.mfd != -1 || errno != ENOENT) break; - sleep(2); } if (rodent.mfd == -1) logerr(1, "unable to open %s", rodent.portname); @@ -855,8 +856,13 @@ usbmodule(void) } } } - if (!loaded && kldload("ums") == -1 && errno != EEXIST) - logerr(1, "unable to load USB mouse driver"); + if (!loaded) { + if (kldload("ums") != -1) + return 1; + if (errno != EEXIST) + logerr(1, "unable to load USB mouse driver"); + } + return 0; } static void -- cgit v1.1