From rmh@khazad.dyndns.org  Sun Feb 20 16:39:15 2005
Return-Path: <rmh@khazad.dyndns.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 1238616A4CE
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 20 Feb 2005 16:39:15 +0000 (GMT)
Received: from khazad.dyndns.org (137.red-62-57-138.user.auna.net [62.57.138.137])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 892D243D2D
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 20 Feb 2005 16:39:14 +0000 (GMT)
	(envelope-from rmh@khazad.dyndns.org)
Received: from rmh by khazad.dyndns.org with local (Exim 4.34)
	id 1D2td5-000KLU-NA
	for FreeBSD-gnats-submit@freebsd.org; Sun, 20 Feb 2005 17:08:19 +0100
Message-Id: <E1D2td5-000KLU-NA@khazad.dyndns.org>
Date: Sun, 20 Feb 2005 17:08:19 +0100
From: Robert Millan <rmh@debian.org>
Reply-To: Robert Millan <rmh@debian.org>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: moused dies when unplugging mouse
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         77786
>Category:       bin
>Synopsis:       moused dies when unplugging mouse
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Feb 20 16:40:28 GMT 2005
>Closed-Date:    Tue Feb 22 09:59:39 GMT 2005
>Last-Modified:  Tue Feb 22 09:59:39 GMT 2005
>Originator:     Robert Millan
>Release:        GNU/kFreeBSD 5.3-3 i686
>Organization:
Debian
>Environment:
System: GNU/kFreeBSD aragorn 5.3-3 #0: Thu Feb 10 15:39:57 CET 2005 i686 GNU/KFreeBSD


	
>Description:
	When moused is being used to process input from an USB mouse, and the
	mouse is dettached, causing the /dev/ums0 to disappear, moused will
	die (complains about open() failing).  So after reattaching the mouse
	you'll have to restart the daemon manualy.

	With this patch, moused's behaviour is closer to what you'd expect from
	a daemon and instead of diing it polls de device untill it can be
	open again.
>How-To-Repeat:
	
>Fix:

I'm not sure if this is exactly what you want.  Perhaps you prefer to get
rid of the strncmp check or comment it out?  Anyway, this works well for me.

--- src.old/usr.sbin/moused/moused.c    2005-02-20 16:47:05.000000000 +0100
+++ src/usr.sbin/moused/moused.c        2005-02-20 16:46:25.000000000 +0100
@@ -778,9 +778,9 @@
        usage();
     }
 
-    retry = 1;
+    retry = 0;
     if (strncmp(rodent.portname, "/dev/ums", 8) == 0) {
-       if (usbmodule() != 0)
+       if ((retry != 0) && (usbmodule() != 0))
            retry = 5;
     }
 
@@ -790,7 +790,7 @@
            signal(SIGINT , cleanup);
            signal(SIGQUIT, cleanup);
            signal(SIGTERM, cleanup);
-           for (i = 0; i < retry; ++i) {
+           for (i = 0; i < retry || retry == 0; ++i) {
                if (i > 0)
                    sleep(2);
                rodent.mfd = open(rodent.portname, O_RDWR | O_NONBLOCK);
>Release-Note:
>Audit-Trail:

From: Gleb Smirnoff <glebius@freebsd.org>
To: Robert Millan <rmh@debian.org>
Cc: FreeBSD-gnats-submit@freebsd.org
Subject: Re: bin/77786: moused dies when unplugging mouse
Date: Mon, 21 Feb 2005 13:29:20 +0300

 On Sun, Feb 20, 2005 at 05:08:19PM +0100, Robert Millan wrote:
 R> >Description:
 R> 	When moused is being used to process input from an USB mouse, and the
 R> 	mouse is dettached, causing the /dev/ums0 to disappear, moused will
 R> 	die (complains about open() failing).  So after reattaching the mouse
 R> 	you'll have to restart the daemon manualy.
 R> 
 R> 	With this patch, moused's behaviour is closer to what you'd expect from
 R> 	a daemon and instead of diing it polls de device untill it can be
 R> 	open again.
 
 This is correct behavior. First, mouse may never return to USB port. What for
 do we need moused daemon running? Second, another mouse can be inserted, with
 another protocol.
 
 The correct fix for your problem is correct /etc/devd.conf, containing this
 attach rule:
 
 attach 100 {
         device-name "ums[0-9]+";
         action "/etc/rc.d/moused start $device-name";
 };
 
 If you don't mind, I close the PR.
 
 -- 
 Totus tuus, Glebius.
 GLEBIUS-RIPN GLEB-RIPE

From: Robert Millan <rmh@debian.org>
To: Gleb Smirnoff <glebius@freebsd.org>
Cc: FreeBSD-gnats-submit@freebsd.org
Subject: Re: bin/77786: moused dies when unplugging mouse
Date: Mon, 21 Feb 2005 15:16:28 +0100

 On Mon, Feb 21, 2005 at 01:29:20PM +0300, Gleb Smirnoff wrote:
 > On Sun, Feb 20, 2005 at 05:08:19PM +0100, Robert Millan wrote:
 > R> >Description:
 > R> 	When moused is being used to process input from an USB mouse, and the
 > R> 	mouse is dettached, causing the /dev/ums0 to disappear, moused will
 > R> 	die (complains about open() failing).  So after reattaching the mouse
 > R> 	you'll have to restart the daemon manualy.
 > R> 
 > R> 	With this patch, moused's behaviour is closer to what you'd expect from
 > R> 	a daemon and instead of diing it polls de device untill it can be
 > R> 	open again.
 > 
 > This is correct behavior. First, mouse may never return to USB port. What for
 > do we need moused daemon running? Second, another mouse can be inserted, with
 > another protocol.
 > 
 > The correct fix for your problem is correct /etc/devd.conf, containing this
 > attach rule:
 > 
 > attach 100 {
 >         device-name "ums[0-9]+";
 >         action "/etc/rc.d/moused start $device-name";
 > };
 > 
 > If you don't mind, I close the PR.
 
 Ah, ok.  Sorry for the confusion.
 
 -- 
  .''`.   Proudly running Debian GNU/kFreeBSD unstable/unreleased (on UFS2+S)
 : :' :
 `. `'    http://www.debian.org/ports/kfreebsd-gnu
   `-
State-Changed-From-To: open->closed 
State-Changed-By: glebius 
State-Changed-When: Tue Feb 22 09:57:43 GMT 2005 
State-Changed-Why:  
Not a bug really. Submitter agrees that PR can be closed. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=77786 
>Unformatted:
