svn commit: r211523 - head/sys/kern

David Xu davidxu at FreeBSD.org
Fri Aug 20 04:28:30 UTC 2010


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.


More information about the svn-src-head mailing list