Module Name:    src
Committed By:   thorpej
Date:           Sun Mar  5 13:49:12 UTC 2023

Modified Files:
        src/sys/dev/usb: ucom.c

Log Message:
In the HUP-wait path in ucomopen():
- Use cv_timedwait() rather than cv_timedwait_sig(); the wait here is
  bounded (and fairly short besides) and seems appropriate to treat like
  other uninterruptible waits.  The behavior is now consistent with com(4)
  in this regard.
- Map EWOULDBLOCK return from cv_timedwait() to 0, as the successful passage
  of time is not an error in this case.
- If the HUP-wait time has passed, clear the HUP-wait timestamp.

kern/57259 (although insufficient -- another change to vfs_syscalls.c
is required)


To generate a diff of this commit:
cvs rdiff -u -r1.136 -r1.137 src/sys/dev/usb/ucom.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/usb/ucom.c
diff -u src/sys/dev/usb/ucom.c:1.136 src/sys/dev/usb/ucom.c:1.137
--- src/sys/dev/usb/ucom.c:1.136	Fri Feb 17 23:44:18 2023
+++ src/sys/dev/usb/ucom.c	Sun Mar  5 13:49:12 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: ucom.c,v 1.136 2023/02/17 23:44:18 riastradh Exp $	*/
+/*	$NetBSD: ucom.c,v 1.137 2023/03/05 13:49:12 thorpej Exp $	*/
 
 /*
  * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ucom.c,v 1.136 2023/02/17 23:44:18 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ucom.c,v 1.137 2023/03/05 13:49:12 thorpej Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -552,11 +552,16 @@ ucomopen(dev_t dev, int flag, int mode, 
 			ms = MIN(INT_MAX - 1000, delta.tv_sec*1000);
 			ms += howmany(delta.tv_usec, 1000);
 			ticks = MAX(1, MIN(INT_MAX, mstohz(ms)));
-			error = cv_timedwait_sig(&sc->sc_statecv, &sc->sc_lock,
+			error = cv_timedwait(&sc->sc_statecv, &sc->sc_lock,
 			    ticks);
 			mutex_exit(&sc->sc_lock);
+			/* The successful passage of time is not an error. */
+			if (error == EWOULDBLOCK) {
+				error = 0;
+			}
 			return error ? error : ERESTART;
 		}
+		timerclear(&sc->sc_hup_time);
 	}
 
 	/*

Reply via email to