From 52fe8a0ecd04ae80559997b70fc1e63202eefabf Mon Sep 17 00:00:00 2001 From: dlg Date: Tue, 24 Dec 2013 01:11:04 +0000 Subject: [PATCH] get rid of if (timeout_pending()) timeout_del(). this is racy. any conditionals you did on timeout_pending can now be done on timeout_del now that it returns what it did. ok and a very good fix from kettenis@ --- sys/arch/loongson/dev/kb3310.c | 5 ++--- sys/arch/sparc/dev/be.c | 5 ++--- sys/kern/kern_synch.c | 5 ++--- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/sys/arch/loongson/dev/kb3310.c b/sys/arch/loongson/dev/kb3310.c index 900a1e7ec14..d670090cf8a 100644 --- a/sys/arch/loongson/dev/kb3310.c +++ b/sys/arch/loongson/dev/kb3310.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kb3310.c,v 1.18 2012/10/03 21:44:51 miod Exp $ */ +/* $OpenBSD: kb3310.c,v 1.19 2013/12/24 01:11:04 dlg Exp $ */ /* * Copyright (c) 2010 Otto Moerbeek * @@ -520,8 +520,7 @@ ykbec_bell(void *arg, u_int pitch, u_int period, u_int volume, int poll) s = spltty(); bctrl = ykbec_read(sc, REG_BEEP_CONTROL); - if (volume == 0 || timeout_pending(&sc->sc_bell_tmo)) { - timeout_del(&sc->sc_bell_tmo); + if (timeout_del(&sc->sc_bell_tmo) || volume == 0) { /* inline ykbec_bell_stop(arg); */ ykbec_write(sc, REG_BEEP_CONTROL, bctrl & ~BEEP_ENABLE); } diff --git a/sys/arch/sparc/dev/be.c b/sys/arch/sparc/dev/be.c index 7a28147cd6e..97b07758c60 100644 --- a/sys/arch/sparc/dev/be.c +++ b/sys/arch/sparc/dev/be.c @@ -1,4 +1,4 @@ -/* $OpenBSD: be.c,v 1.45 2013/11/27 08:56:31 mpi Exp $ */ +/* $OpenBSD: be.c,v 1.46 2013/12/24 01:11:04 dlg Exp $ */ /* * Copyright (c) 1998 Theo de Raadt and Jason L. Wright. @@ -323,8 +323,7 @@ bestop(sc) int tries; sc->sc_arpcom.ac_if.if_timer = 0; - if (timeout_pending(&sc->sc_tick)) - timeout_del(&sc->sc_tick); + timeout_del(&sc->sc_tick); tries = 32; sc->sc_br->tx_cfg = 0; diff --git a/sys/kern/kern_synch.c b/sys/kern/kern_synch.c index 84f0028289a..c480e46f80f 100644 --- a/sys/kern/kern_synch.c +++ b/sys/kern/kern_synch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_synch.c,v 1.111 2013/11/25 15:24:18 tedu Exp $ */ +/* $OpenBSD: kern_synch.c,v 1.112 2013/12/24 01:11:04 dlg Exp $ */ /* $NetBSD: kern_synch.c,v 1.37 1996/04/22 01:38:37 christos Exp $ */ /* @@ -263,9 +263,8 @@ sleep_finish_timeout(struct sleep_state *sls) if (p->p_flag & P_TIMEOUT) { atomic_clearbits_int(&p->p_flag, P_TIMEOUT); return (EWOULDBLOCK); - } else if (timeout_pending(&p->p_sleep_to)) { + } else timeout_del(&p->p_sleep_to); - } return (0); } -- 2.20.1