Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern Properly differentiate between infinite timeout and...
details: https://anonhg.NetBSD.org/src/rev/552a9a4008a9
branches: trunk
changeset: 785317:552a9a4008a9
user: apb <apb%NetBSD.org@localhost>
date: Fri Mar 08 09:32:59 2013 +0000
description:
Properly differentiate between infinite timeout and zero timeout.
Local variable timo = -1 is used for zero timeout (non blocking mode).
Fixes PR 47625 from anthony.mallet
diffstat:
sys/kern/sys_sig.c | 20 +++++++++++++++-----
1 files changed, 15 insertions(+), 5 deletions(-)
diffs (55 lines):
diff -r de6657a601d2 -r 552a9a4008a9 sys/kern/sys_sig.c
--- a/sys/kern/sys_sig.c Fri Mar 08 08:48:38 2013 +0000
+++ b/sys/kern/sys_sig.c Fri Mar 08 09:32:59 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sys_sig.c,v 1.40 2013/03/08 08:48:38 apb Exp $ */
+/* $NetBSD: sys_sig.c,v 1.41 2013/03/08 09:32:59 apb Exp $ */
/*-
* Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -66,7 +66,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sys_sig.c,v 1.40 2013/03/08 08:48:38 apb Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_sig.c,v 1.41 2013/03/08 09:32:59 apb Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@@ -728,8 +728,12 @@
return error;
timo = tstohz(&ts);
- if (timo == 0 && ts.tv_sec == 0 && ts.tv_nsec != 0)
- timo++;
+ if (timo == 0) {
+ if (ts.tv_sec == 0 && ts.tv_nsec == 0)
+ timo = -1; /* do not block */
+ else
+ timo = 1; /* the shortest possible timeout */
+ }
/*
* Remember current uptime, it would be used in
@@ -738,7 +742,7 @@
getnanouptime(&tsstart);
} else {
memset(&tsstart, 0, sizeof(tsstart)); /* XXXgcc */
- timo = 0;
+ timo = 0; /* infinite timeout */
}
error = (*fetchss)(SCARG(uap, set), &l->l_sigwaitset,
@@ -765,6 +769,12 @@
goto out;
}
+ if (timo < 0) {
+ /* If not allowed to block, return an error */
+ mutex_exit(p->p_lock);
+ return EAGAIN;
+ }
+
/*
* Set up the sigwait list and wait for signal to arrive.
* We can either be woken up or time out.
Home |
Main Index |
Thread Index |
Old Index