Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 20 Nov 2012 15:33:48 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r243341 - head/sys/kern
Message-ID:  <201211201533.qAKFXm80046544@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Tue Nov 20 15:33:48 2012
New Revision: 243341
URL: http://svnweb.freebsd.org/changeset/base/243341

Log:
  Add a special meaning to the negative ticks argument for
  taskqueue_enqueue_timeout().  Do not rearm the callout if it is
  already armed and the ticks is negative.  Otherwise rearm it to fire
  in abs(ticks) ticks in the future.
  
  The intended use is to call taskqueue_enqueue_timeout() for the given
  timeout_task with the same negative ticks argument.  As result, the
  task is scheduled to execute not further than abs(ticks) ticks in
  future, and the consequent enqueues are coalesced until the already
  scheduled task is finished.
  
  Reviewed by:	rwatson
  Tested by:	Markus Gebert <markus.gebert@hostpoint.ch>
  MFC after:	2 weeks

Modified:
  head/sys/kern/subr_taskqueue.c

Modified: head/sys/kern/subr_taskqueue.c
==============================================================================
--- head/sys/kern/subr_taskqueue.c	Tue Nov 20 15:25:00 2012	(r243340)
+++ head/sys/kern/subr_taskqueue.c	Tue Nov 20 15:33:48 2012	(r243341)
@@ -252,9 +252,13 @@ taskqueue_enqueue_timeout(struct taskque
 		} else {
 			queue->tq_callouts++;
 			timeout_task->f |= DT_CALLOUT_ARMED;
+			if (ticks < 0)
+				ticks = -ticks; /* Ignore overflow. */
+		}
+		if (ticks > 0) {
+			callout_reset(&timeout_task->c, ticks,
+			    taskqueue_timeout_func, timeout_task);
 		}
-		callout_reset(&timeout_task->c, ticks, taskqueue_timeout_func,
-		    timeout_task);
 	}
 	TQ_UNLOCK(queue);
 	return (res);



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