Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 20 Aug 2010 04:28:30 +0000 (UTC)
From:      David Xu <davidxu@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r211523 - head/sys/kern
Message-ID:  <201008200428.o7K4SUYU026144@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: davidxu
Date: Fri Aug 20 04:28:30 2010
New Revision: 211523
URL: http://svn.freebsd.org/changeset/base/211523

Log:
  If thread set a TDP_WAKEUP for itself, clears the flag and returns EINTR
  immediately, this is used for implementing reliable pthread cancellation.

Modified:
  head/sys/kern/subr_sleepqueue.c

Modified: head/sys/kern/subr_sleepqueue.c
==============================================================================
--- head/sys/kern/subr_sleepqueue.c	Fri Aug 20 04:15:05 2010	(r211522)
+++ head/sys/kern/subr_sleepqueue.c	Fri Aug 20 04:28:30 2010	(r211523)
@@ -408,6 +408,12 @@ sleepq_catch_signals(void *wchan, int pr
 	sc = SC_LOOKUP(wchan);
 	mtx_assert(&sc->sc_lock, MA_OWNED);
 	MPASS(wchan != NULL);
+	if ((td->td_pflags & TDP_WAKEUP) != 0) {
+		td->td_pflags &= ~TDP_WAKEUP;
+		ret = EINTR;
+		goto out;
+	}
+
 	/*
 	 * See if there are any pending signals for this thread.  If not
 	 * we can switch immediately.  Otherwise do the signal processing
@@ -453,6 +459,7 @@ sleepq_catch_signals(void *wchan, int pr
 		sleepq_switch(wchan, pri);
 		return (0);
 	}
+out:
 	/*
 	 * There were pending signals and this thread is still
 	 * on the sleep queue, remove it from the sleep queue.



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