Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 13 Nov 2015 22:51:36 +0000 (UTC)
From:      Randall Stewart <rrs@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r290805 - in head: share/man/man9 sys/kern sys/net sys/netinet sys/netinet6 sys/netpfil/pf
Message-ID:  <201511132251.tADMpa8o053824@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: rrs
Date: Fri Nov 13 22:51:35 2015
New Revision: 290805
URL: https://svnweb.freebsd.org/changeset/base/290805

Log:
  This fixes several places where callout_stops return is examined. The
  new return codes of -1 were mistakenly being considered "true". Callout_stop
  now returns -1 to indicate the callout had either already completed or
  was not running and 0 to indicate it could not be stopped.  Also update
  the manual page to make it more consistent no non-zero in the callout_stop
  or callout_reset descriptions.
  
  MFC after:	1 Month with associated callout change.

Modified:
  head/share/man/man9/timeout.9
  head/sys/kern/subr_taskqueue.c
  head/sys/net/if_llatbl.c
  head/sys/netinet/in.c
  head/sys/netinet/tcp_timer.c
  head/sys/netinet6/in6.c
  head/sys/netinet6/nd6.c
  head/sys/netpfil/pf/if_pfsync.c

Modified: head/share/man/man9/timeout.9
==============================================================================
--- head/share/man/man9/timeout.9	Fri Nov 13 22:33:51 2015	(r290804)
+++ head/share/man/man9/timeout.9	Fri Nov 13 22:51:35 2015	(r290805)
@@ -302,7 +302,7 @@ If
 .Fa c
 already has a pending callout,
 it is cancelled before the new invocation is scheduled.
-These functions return a non-zero value if a pending callout was cancelled
+These functions return a value of one if a pending callout was cancelled
 and zero if there was no pending callout.
 If the callout has an associated lock,
 then that lock must be held when any of these functions are called.
@@ -804,16 +804,16 @@ The
 .Fn callout_reset
 and
 .Fn callout_schedule
-function families return non-zero if the callout was pending before the new
+function families return a value of one if the callout was pending before the new
 function invocation was scheduled.
 .Pp
 The
 .Fn callout_stop
 and
 .Fn callout_drain
-functions return non-zero if the callout was still pending when it was
-called or zero otherwise.
-The
+functions return a value of one if the callout was still pending when it was
+called, a zero if the callout could not be stopped and a negative one is it
+was either not running or haas already completed. The
 .Fn timeout
 function returns a
 .Ft struct callout_handle

Modified: head/sys/kern/subr_taskqueue.c
==============================================================================
--- head/sys/kern/subr_taskqueue.c	Fri Nov 13 22:33:51 2015	(r290804)
+++ head/sys/kern/subr_taskqueue.c	Fri Nov 13 22:51:35 2015	(r290805)
@@ -496,7 +496,7 @@ taskqueue_cancel_timeout(struct taskqueu
 	int error;
 
 	TQ_LOCK(queue);
-	pending = !!callout_stop(&timeout_task->c);
+	pending = !!(callout_stop(&timeout_task->c) > 0);
 	error = taskqueue_cancel_locked(queue, &timeout_task->t, &pending1);
 	if ((timeout_task->f & DT_CALLOUT_ARMED) != 0) {
 		timeout_task->f &= ~DT_CALLOUT_ARMED;

Modified: head/sys/net/if_llatbl.c
==============================================================================
--- head/sys/net/if_llatbl.c	Fri Nov 13 22:33:51 2015	(r290804)
+++ head/sys/net/if_llatbl.c	Fri Nov 13 22:51:35 2015	(r290805)
@@ -394,7 +394,7 @@ lltable_free(struct lltable *llt)
 	IF_AFDATA_WUNLOCK(llt->llt_ifp);
 
 	LIST_FOREACH_SAFE(lle, &dchain, lle_chain, next) {
-		if (callout_stop(&lle->lle_timer))
+		if (callout_stop(&lle->lle_timer) > 0)
 			LLE_REMREF(lle);
 		llentry_free(lle);
 	}

Modified: head/sys/netinet/in.c
==============================================================================
--- head/sys/netinet/in.c	Fri Nov 13 22:33:51 2015	(r290804)
+++ head/sys/netinet/in.c	Fri Nov 13 22:51:35 2015	(r290805)
@@ -1093,7 +1093,7 @@ in_lltable_free_entry(struct lltable *ll
 	}
 
 	/* cancel timer */
-	if (callout_stop(&lle->lle_timer))
+	if (callout_stop(&lle->lle_timer) > 0)
 		LLE_REMREF(lle);
 
 	/* Drop hold queue */

Modified: head/sys/netinet/tcp_timer.c
==============================================================================
--- head/sys/netinet/tcp_timer.c	Fri Nov 13 22:33:51 2015	(r290804)
+++ head/sys/netinet/tcp_timer.c	Fri Nov 13 22:51:35 2015	(r290805)
@@ -862,7 +862,7 @@ tcp_timer_activate(struct tcpcb *tp, uin
 		}
 	if (delta == 0) {
 		if ((tp->t_timers->tt_flags & timer_type) &&
-		    callout_stop(t_callout) &&
+		    (callout_stop(t_callout) > 0) &&
 		    (tp->t_timers->tt_flags & f_reset)) {
 			tp->t_timers->tt_flags &= ~(timer_type | f_reset);
 		}
@@ -949,7 +949,7 @@ tcp_timer_stop(struct tcpcb *tp, uint32_
 		}
 
 	if (tp->t_timers->tt_flags & timer_type) {
-		if (callout_stop(t_callout) &&
+		if ((callout_stop(t_callout) > 0) &&
 		    (tp->t_timers->tt_flags & f_reset)) {
 			tp->t_timers->tt_flags &= ~(timer_type | f_reset);
 		} else {

Modified: head/sys/netinet6/in6.c
==============================================================================
--- head/sys/netinet6/in6.c	Fri Nov 13 22:33:51 2015	(r290804)
+++ head/sys/netinet6/in6.c	Fri Nov 13 22:51:35 2015	(r290805)
@@ -2133,7 +2133,7 @@ in6_lltable_free_entry(struct lltable *l
 		lltable_unlink_entry(llt, lle);
 	}
 
-	if (callout_stop(&lle->lle_timer))
+	if (callout_stop(&lle->lle_timer) > 0)
 		LLE_REMREF(lle);
 
 	llentry_free(lle);

Modified: head/sys/netinet6/nd6.c
==============================================================================
--- head/sys/netinet6/nd6.c	Fri Nov 13 22:33:51 2015	(r290804)
+++ head/sys/netinet6/nd6.c	Fri Nov 13 22:51:35 2015	(r290805)
@@ -508,7 +508,7 @@ nd6_llinfo_settimer_locked(struct llentr
 			    nd6_llinfo_timer, ln);
 		}
 	}
-	if (canceled)
+	if (canceled > 0)
 		LLE_REMREF(ln);
 }
 

Modified: head/sys/netpfil/pf/if_pfsync.c
==============================================================================
--- head/sys/netpfil/pf/if_pfsync.c	Fri Nov 13 22:33:51 2015	(r290804)
+++ head/sys/netpfil/pf/if_pfsync.c	Fri Nov 13 22:51:35 2015	(r290805)
@@ -352,7 +352,7 @@ pfsync_clone_destroy(struct ifnet *ifp)
 
 		TAILQ_REMOVE(&sc->sc_deferrals, pd, pd_entry);
 		sc->sc_deferred--;
-		if (callout_stop(&pd->pd_tmo)) {
+		if (callout_stop(&pd->pd_tmo) > 0) {
 			pf_release_state(pd->pd_st);
 			m_freem(pd->pd_m);
 			free(pd, M_PFSYNC);
@@ -1775,7 +1775,7 @@ pfsync_undefer_state(struct pf_state *st
 
 	TAILQ_FOREACH(pd, &sc->sc_deferrals, pd_entry) {
 		 if (pd->pd_st == st) {
-			if (callout_stop(&pd->pd_tmo))
+			if (callout_stop(&pd->pd_tmo) > 0)
 				pfsync_undefer(pd, drop);
 			return;
 		}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201511132251.tADMpa8o053824>