PERFORCE change 67320 for review

Sam Leffler sam at FreeBSD.org
Sat Dec 18 16:56:01 PST 2004


http://perforce.freebsd.org/chv.cgi?CH=67320

Change 67320 by sam at sam_ebb on 2004/12/19 00:55:52

	IFC @ 67319

Affected files ...

.. //depot/projects/wifi/Makefile#5 integrate
.. //depot/projects/wifi/Makefile.inc1#7 integrate
.. //depot/projects/wifi/UPDATING.64BTT#2 delete
.. //depot/projects/wifi/contrib/groff/tmac/doc-common#2 integrate
.. //depot/projects/wifi/etc/rc.d/named#2 integrate
.. //depot/projects/wifi/gnu/usr.bin/groff/tmac/mdoc.local#2 integrate
.. //depot/projects/wifi/installworld_newk#2 delete
.. //depot/projects/wifi/installworld_oldk#2 delete
.. //depot/projects/wifi/lib/libc/gen/sigsetops.3#2 integrate
.. //depot/projects/wifi/lib/libpthread/pthread.map#2 integrate
.. //depot/projects/wifi/lib/libpthread/sys/thr_error.c#2 integrate
.. //depot/projects/wifi/lib/libpthread/thread/thr_cancel.c#2 integrate
.. //depot/projects/wifi/lib/libpthread/thread/thr_clean.c#2 integrate
.. //depot/projects/wifi/lib/libpthread/thread/thr_concurrency.c#2 integrate
.. //depot/projects/wifi/lib/libpthread/thread/thr_cond.c#2 integrate
.. //depot/projects/wifi/lib/libpthread/thread/thr_create.c#2 integrate
.. //depot/projects/wifi/lib/libpthread/thread/thr_fork.c#2 integrate
.. //depot/projects/wifi/lib/libpthread/thread/thr_init.c#2 integrate
.. //depot/projects/wifi/lib/libpthread/thread/thr_kern.c#2 integrate
.. //depot/projects/wifi/lib/libpthread/thread/thr_mutex.c#3 integrate
.. //depot/projects/wifi/lib/libpthread/thread/thr_once.c#2 integrate
.. //depot/projects/wifi/lib/libpthread/thread/thr_private.h#3 integrate
.. //depot/projects/wifi/lib/libpthread/thread/thr_sem.c#2 integrate
.. //depot/projects/wifi/lib/libpthread/thread/thr_sig.c#3 integrate
.. //depot/projects/wifi/lib/libpthread/thread/thr_sigsuspend.c#2 integrate
.. //depot/projects/wifi/lib/libpthread/thread/thr_spinlock.c#2 integrate
.. //depot/projects/wifi/lib/libutil/_secure_path.c#2 integrate
.. //depot/projects/wifi/lib/msun/bsdsrc/b_exp.c#2 integrate
.. //depot/projects/wifi/lib/msun/bsdsrc/b_log.c#2 integrate
.. //depot/projects/wifi/lib/msun/bsdsrc/b_tgamma.c#2 integrate
.. //depot/projects/wifi/lib/msun/bsdsrc/mathimpl.h#2 integrate
.. //depot/projects/wifi/libexec/ftpd/ftpd.c#8 integrate
.. //depot/projects/wifi/release/doc/en_US.ISO8859-1/hardware/common/dev.sgml#7 integrate
.. //depot/projects/wifi/release/doc/share/misc/dev.archlist.txt#6 integrate
.. //depot/projects/wifi/rescue/rescue/Makefile#5 integrate
.. //depot/projects/wifi/sbin/mknod/mknod.8#2 integrate
.. //depot/projects/wifi/share/examples/etc/make.conf#6 integrate
.. //depot/projects/wifi/share/man/man4/altq.4#5 integrate
.. //depot/projects/wifi/share/man/man4/ath.4#4 integrate
.. //depot/projects/wifi/share/man/man4/atkbd.4#2 integrate
.. //depot/projects/wifi/share/man/man4/bge.4#2 integrate
.. //depot/projects/wifi/share/man/man4/divert.4#2 integrate
.. //depot/projects/wifi/share/man/man4/fwohci.4#3 integrate
.. //depot/projects/wifi/share/man/man4/mpt.4#2 integrate
.. //depot/projects/wifi/share/man/man4/netgraph.4#2 integrate
.. //depot/projects/wifi/share/man/man4/ng_bt3c.4#2 integrate
.. //depot/projects/wifi/share/man/man4/ng_netflow.4#2 integrate
.. //depot/projects/wifi/share/man/man4/smp.4#3 integrate
.. //depot/projects/wifi/share/man/man4/ti.4#2 integrate
.. //depot/projects/wifi/share/man/man4/ubser.4#2 integrate
.. //depot/projects/wifi/share/man/man4/umass.4#2 integrate
.. //depot/projects/wifi/share/man/man5/rc.conf.5#5 integrate
.. //depot/projects/wifi/share/man/man7/hier.7#2 integrate
.. //depot/projects/wifi/share/man/man7/ports.7#3 integrate
.. //depot/projects/wifi/share/man/man7/release.7#2 integrate
.. //depot/projects/wifi/sys/alpha/alpha/pmap.c#3 integrate
.. //depot/projects/wifi/sys/amd64/amd64/pmap.c#5 integrate
.. //depot/projects/wifi/sys/arm/arm/pmap.c#5 integrate
.. //depot/projects/wifi/sys/arm/conf/SIMICS#4 integrate
.. //depot/projects/wifi/sys/arm/include/atomic.h#3 integrate
.. //depot/projects/wifi/sys/arm/sa11x0/assabet_machdep.c#3 integrate
.. //depot/projects/wifi/sys/arm/sa11x0/sa11x0_irqhandler.c#2 integrate
.. //depot/projects/wifi/sys/contrib/ipfilter/netinet/fil.c#2 integrate
.. //depot/projects/wifi/sys/contrib/ipfilter/netinet/ip_nat.c#2 integrate
.. //depot/projects/wifi/sys/dev/bge/if_bge.c#5 integrate
.. //depot/projects/wifi/sys/dev/bge/if_bgereg.h#3 integrate
.. //depot/projects/wifi/sys/dev/bktr/bktr_card.c#2 integrate
.. //depot/projects/wifi/sys/dev/bktr/bktr_card.h#2 integrate
.. //depot/projects/wifi/sys/dev/bktr/bktr_tuner.c#2 integrate
.. //depot/projects/wifi/sys/dev/bktr/bktr_tuner.h#2 integrate
.. //depot/projects/wifi/sys/dev/bktr/msp34xx.c#2 integrate
.. //depot/projects/wifi/sys/dev/kbd/atkbd.c#2 integrate
.. //depot/projects/wifi/sys/dev/kbd/atkbdreg.h#2 integrate
.. //depot/projects/wifi/sys/dev/mpt/mpt_pci.c#2 integrate
.. //depot/projects/wifi/sys/dev/twe/twe.c#2 integrate
.. //depot/projects/wifi/sys/dev/twe/tweio.h#2 integrate
.. //depot/projects/wifi/sys/dev/usb/ehci.c#6 integrate
.. //depot/projects/wifi/sys/dev/wi/if_wi.c#9 edit
.. //depot/projects/wifi/sys/i386/i386/pmap.c#7 integrate
.. //depot/projects/wifi/sys/ia64/ia64/pmap.c#4 integrate
.. //depot/projects/wifi/sys/kern/init_sysent.c#4 integrate
.. //depot/projects/wifi/sys/kern/kern_umtx.c#3 integrate
.. //depot/projects/wifi/sys/kern/syscalls.c#4 integrate
.. //depot/projects/wifi/sys/kern/syscalls.master#4 integrate
.. //depot/projects/wifi/sys/modules/wlan_ccmp/Makefile#5 integrate
.. //depot/projects/wifi/sys/net/bpf.c#4 integrate
.. //depot/projects/wifi/sys/nfsclient/nfs.h#3 integrate
.. //depot/projects/wifi/sys/nfsclient/nfs_bio.c#7 integrate
.. //depot/projects/wifi/sys/nfsclient/nfs_nfsiod.c#3 integrate
.. //depot/projects/wifi/sys/nfsclient/nfs_vfsops.c#5 integrate
.. //depot/projects/wifi/sys/nfsclient/nfs_vnops.c#9 integrate
.. //depot/projects/wifi/sys/nfsclient/nfsnode.h#6 integrate
.. //depot/projects/wifi/sys/powerpc/powerpc/pmap.c#2 integrate
.. //depot/projects/wifi/sys/sparc64/sparc64/pmap.c#4 integrate
.. //depot/projects/wifi/sys/sys/proc.h#4 integrate
.. //depot/projects/wifi/sys/sys/syscall.h#3 integrate
.. //depot/projects/wifi/sys/sys/syscall.mk#3 integrate
.. //depot/projects/wifi/sys/sys/sysproto.h#3 integrate
.. //depot/projects/wifi/sys/sys/umtx.h#2 integrate
.. //depot/projects/wifi/sys/vm/vm_fault.c#2 integrate
.. //depot/projects/wifi/sys/vm/vm_map.c#2 integrate
.. //depot/projects/wifi/sys/vm/vm_meter.c#2 integrate
.. //depot/projects/wifi/sys/vm/vm_object.c#4 integrate
.. //depot/projects/wifi/tools/tools/nanobsd/Customize/comconsole#2 integrate
.. //depot/projects/wifi/usr.bin/calendar/calendars/calendar.freebsd#5 integrate
.. //depot/projects/wifi/usr.bin/calendar/calendars/calendar.music#2 integrate
.. //depot/projects/wifi/usr.bin/calendar/calendars/de_DE.ISO8859-1/calendar.musik#2 integrate
.. //depot/projects/wifi/usr.bin/make/Makefile#5 integrate
.. //depot/projects/wifi/usr.bin/make/arch.c#6 integrate
.. //depot/projects/wifi/usr.bin/make/compat.c#6 integrate
.. //depot/projects/wifi/usr.bin/make/cond.c#5 integrate
.. //depot/projects/wifi/usr.bin/make/dir.c#6 integrate
.. //depot/projects/wifi/usr.bin/make/dir.h#4 integrate
.. //depot/projects/wifi/usr.bin/make/for.c#5 integrate
.. //depot/projects/wifi/usr.bin/make/job.c#10 integrate
.. //depot/projects/wifi/usr.bin/make/lst.h#5 integrate
.. //depot/projects/wifi/usr.bin/make/lst.lib/lstConcat.c#6 integrate
.. //depot/projects/wifi/usr.bin/make/lst.lib/lstDestroy.c#7 integrate
.. //depot/projects/wifi/usr.bin/make/lst.lib/lstDupl.c#6 integrate
.. //depot/projects/wifi/usr.bin/make/lst.lib/lstInit.c#6 delete
.. //depot/projects/wifi/usr.bin/make/main.c#10 integrate
.. //depot/projects/wifi/usr.bin/make/make.c#7 integrate
.. //depot/projects/wifi/usr.bin/make/make.h#4 integrate
.. //depot/projects/wifi/usr.bin/make/nonints.h#5 integrate
.. //depot/projects/wifi/usr.bin/make/parse.c#7 integrate
.. //depot/projects/wifi/usr.bin/make/str.c#5 integrate
.. //depot/projects/wifi/usr.bin/make/suff.c#6 integrate
.. //depot/projects/wifi/usr.bin/make/targ.c#7 integrate
.. //depot/projects/wifi/usr.bin/make/var.c#7 integrate
.. //depot/projects/wifi/usr.sbin/boot0cfg/boot0cfg.c#2 integrate
.. //depot/projects/wifi/usr.sbin/burncd/burncd.c#2 integrate
.. //depot/projects/wifi/usr.sbin/config/config.8#2 integrate
.. //depot/projects/wifi/usr.sbin/lpr/lpd/printjob.c#2 integrate
.. //depot/projects/wifi/usr.sbin/ppp/ppp.8.m4#5 integrate

Differences ...

==== //depot/projects/wifi/Makefile#5 (text+ko) ====

@@ -1,5 +1,5 @@
 #
-# $FreeBSD: src/Makefile,v 1.312 2004/12/13 00:49:52 marcel Exp $
+# $FreeBSD: src/Makefile,v 1.313 2004/12/16 19:55:57 ru Exp $
 #
 # The user-driven targets are:
 #
@@ -86,8 +86,9 @@
 
 PATH=	/sbin:/bin:/usr/sbin:/usr/bin
 MAKEOBJDIRPREFIX?=	/usr/obj
-_MAKEOBJDIRPREFIX!= /usr/bin/env -i PATH=${PATH} ${MAKE} ${.MAKEFLAGS} \
-		-f /dev/null -V MAKEOBJDIRPREFIX dummy
+_MAKEOBJDIRPREFIX!= /usr/bin/env -i PATH=${PATH} ${MAKE} \
+    ${.MAKEFLAGS:MMAKEOBJDIRPREFIX=*} \
+    -f /dev/null -V MAKEOBJDIRPREFIX dummy
 .if !empty(_MAKEOBJDIRPREFIX)
 .error MAKEOBJDIRPREFIX can only be set in environment, not as a global\
 	(in /etc/make.conf) or command-line variable.

==== //depot/projects/wifi/Makefile.inc1#7 (text+ko) ====

@@ -1,5 +1,5 @@
 #
-# $FreeBSD: src/Makefile.inc1,v 1.459 2004/12/01 23:23:14 peter Exp $
+# $FreeBSD: src/Makefile.inc1,v 1.460 2004/12/17 10:11:33 ru Exp $
 #
 # Make command line options:
 #	-DNO_DYNAMICROOT do not link /bin and /sbin dynamically
@@ -27,7 +27,7 @@
 # The intended user-driven targets are:
 # buildworld  - rebuild *everything*, including glue to help do upgrades
 # installworld- install everything built by "buildworld"
-# update      - convenient way to update your source tree (eg: sup/cvs)
+# update      - convenient way to update your source tree (eg: cvsup/cvs)
 #
 # Standard targets (not defined here) are documented in the makefiles in
 # /usr/share/mk.  These include:
@@ -739,7 +739,7 @@
 #
 # update
 #
-# Update the source tree, by running sup and/or running cvs to update to the
+# Update the source tree, by running cvsup and/or running cvs to update to the
 # latest copy.
 #
 update:
@@ -765,7 +765,7 @@
 .endif
 .if defined(CVS_UPDATE)
 	@echo "--------------------------------------------------------------"
-	@echo ">>> Updating ${.CURDIR} from cvs repository" ${CVSROOT}
+	@echo ">>> Updating ${.CURDIR} from CVS repository" ${CVSROOT}
 	@echo "--------------------------------------------------------------"
 	cd ${.CURDIR}; ${CVS} -R -q update ${CVSFLAGS}
 .endif

==== //depot/projects/wifi/contrib/groff/tmac/doc-common#2 (text+ko) ====


==== //depot/projects/wifi/etc/rc.d/named#2 (text+ko) ====

@@ -1,7 +1,7 @@
 #!/bin/sh
 #
 # $NetBSD: named,v 1.10 2002/03/22 04:33:59 thorpej Exp $
-# $FreeBSD: src/etc/rc.d/named,v 1.16 2004/10/07 13:55:26 mtm Exp $
+# $FreeBSD: src/etc/rc.d/named,v 1.17 2004/12/18 15:19:36 phk Exp $
 #
 
 # PROVIDE: named
@@ -48,6 +48,10 @@
 		else
 			ln -s ${named_chrootdir}/etc/namedb /etc/namedb
 		fi
+	else
+		# Make sure it points to the right place.
+		ln -sf ${named_chrootdir}/etc/namedb /etc/namedb
+
 	fi
 
 	# Mount a devfs in the chroot directory if needed

==== //depot/projects/wifi/gnu/usr.bin/groff/tmac/mdoc.local#2 (text+ko) ====

@@ -22,7 +22,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.\" $FreeBSD: src/gnu/usr.bin/groff/tmac/mdoc.local,v 1.42 2004/08/19 10:41:54 ru Exp $
+.\" $FreeBSD: src/gnu/usr.bin/groff/tmac/mdoc.local,v 1.44 2004/12/18 07:20:33 ru Exp $
 .\"
 .\"     %beginstrip%
 .
@@ -60,9 +60,9 @@
 .ds doc-default-operating-system FreeBSD\~6.0
 .
 .\" FreeBSD releases not found in doc-common
-.\" .ds doc-operating-system-FreeBSD-4.11   4.11
-.\" .ds doc-operating-system-FreeBSD-5.4    5.4
-.\" .ds doc-operating-system-FreeBSD-6.0    6.0
+.ds doc-operating-system-FreeBSD-4.11   4.11
+.ds doc-operating-system-FreeBSD-5.4    5.4
+.ds doc-operating-system-FreeBSD-6.0    6.0
 .
 .ec
 .

==== //depot/projects/wifi/lib/libc/gen/sigsetops.3#2 (text+ko) ====

@@ -30,9 +30,9 @@
 .\" SUCH DAMAGE.
 .\"
 .\"     @(#)sigsetops.3	8.1 (Berkeley) 6/4/93
-.\" $FreeBSD: src/lib/libc/gen/sigsetops.3,v 1.8 2003/06/24 15:27:31 yar Exp $
+.\" $FreeBSD: src/lib/libc/gen/sigsetops.3,v 1.9 2004/12/16 20:27:55 maxim Exp $
 .\"
-.Dd June 4, 1993
+.Dd December 16, 2004
 .Dt SIGSETOPS 3
 .Os
 .Sh NAME
@@ -92,21 +92,24 @@
 function returns whether a specified signal
 .Fa signo
 is contained in the signal set.
-.Pp
-These functions
-are provided as macros in the include file <signal.h>.
-Actual functions are available
-if their names are undefined (with
-.Ic #undef Ar name ) .
 .Sh RETURN VALUES
 The
 .Fn sigismember
 function returns 1
 if the signal is a member of the set,
 0 otherwise.
-The other functions return 0.
+The other functions return 0 upon success.
+A \-1 return value
+indicates an error occurred and the global variable
+.Va errno
+is set to indicate the reason.
 .Sh ERRORS
-Currently no errors are detected.
+These functions could fail if one of the following occurs:
+.Bl -tag -width Er
+.It Bq Er EINVAL
+.Fa signo
+has an invalid value.
+.El
 .Sh SEE ALSO
 .Xr kill 2 ,
 .Xr sigaction 2 ,

==== //depot/projects/wifi/lib/libpthread/pthread.map#2 (text+ko) ====

@@ -1,4 +1,4 @@
-# $FreeBSD: src/lib/libpthread/pthread.map,v 1.13 2004/09/26 06:50:14 deischen Exp $
+# $FreeBSD: src/lib/libpthread/pthread.map,v 1.14 2004/12/18 18:07:36 deischen Exp $
 LIBTHREAD_1_0 {
 global:
 	___creat;
@@ -14,6 +14,7 @@
 	__poll;
 	__pthread_cond_timedwait;
 	__pthread_cond_wait;
+	__pthread_mutex_init;
 	__pthread_mutex_lock;
 	__pthread_mutex_trylock;
 	__pthread_mutex_timedlock;

==== //depot/projects/wifi/lib/libpthread/sys/thr_error.c#2 (text+ko) ====

@@ -31,12 +31,13 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/lib/libpthread/sys/thr_error.c,v 1.7 2003/04/23 21:46:50 deischen Exp $
+ * $FreeBSD: src/lib/libpthread/sys/thr_error.c,v 1.8 2004/12/18 18:07:37 deischen Exp $
  */
 #include <pthread.h>
 #include "libc_private.h"
 #include "thr_private.h"
 
+#undef errno
 extern	int	errno;
 
 int *

==== //depot/projects/wifi/lib/libpthread/thread/thr_cancel.c#2 (text+ko) ====

@@ -1,6 +1,6 @@
 /*
  * David Leonard <d at openbsd.org>, 1999. Public domain.
- * $FreeBSD: src/lib/libpthread/thread/thr_cancel.c,v 1.31 2003/12/09 02:20:56 davidxu Exp $
+ * $FreeBSD: src/lib/libpthread/thread/thr_cancel.c,v 1.32 2004/12/18 18:07:37 deischen Exp $
  */
 #include <sys/errno.h>
 #include <pthread.h>
@@ -14,18 +14,26 @@
 static inline int
 checkcancel(struct pthread *curthread)
 {
-	if (((curthread->cancelflags & PTHREAD_CANCEL_DISABLE) == 0) &&
-	    ((curthread->cancelflags & THR_CANCELLING) != 0)) {
+	if ((curthread->cancelflags & THR_CANCELLING) != 0) {
 		/*
 		 * It is possible for this thread to be swapped out
 		 * while performing cancellation; do not allow it
 		 * to be cancelled again.
 		 */
-		curthread->cancelflags &= ~THR_CANCELLING;
-		return (1);
+		if ((curthread->flags & THR_FLAGS_EXITING) != 0) {
+			/*
+			 * This may happen once, but after this, it
+			 * shouldn't happen again.
+			 */
+			curthread->cancelflags &= ~THR_CANCELLING;
+			return (0);
+		}
+		if ((curthread->cancelflags & PTHREAD_CANCEL_DISABLE) == 0) {
+			curthread->cancelflags &= ~THR_CANCELLING;
+			return (1);
+		}
 	}
-	else
-		return (0);
+	return (0);
 }
 
 static inline void

==== //depot/projects/wifi/lib/libpthread/thread/thr_clean.c#2 (text+ko) ====

@@ -29,7 +29,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/lib/libpthread/thread/thr_clean.c,v 1.8 2003/04/18 05:04:15 deischen Exp $
+ * $FreeBSD: src/lib/libpthread/thread/thr_clean.c,v 1.9 2004/12/18 18:07:37 deischen Exp $
  */
 #include <signal.h>
 #include <errno.h>
@@ -50,6 +50,7 @@
 	    malloc(sizeof(struct pthread_cleanup))) != NULL) {
 		new->routine = routine;
 		new->routine_arg = routine_arg;
+		new->onstack = 0;
 		new->next = curthread->cleanup;
 
 		curthread->cleanup = new;
@@ -67,6 +68,7 @@
 		if (execute) {
 			old->routine(old->routine_arg);
 		}
-		free(old);
+		if (old->onstack == 0)
+			free(old);
 	}
 }

==== //depot/projects/wifi/lib/libpthread/thread/thr_concurrency.c#2 (text+ko) ====

@@ -24,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/lib/libpthread/thread/thr_concurrency.c,v 1.8 2004/03/14 05:24:27 bde Exp $
+ * $FreeBSD: src/lib/libpthread/thread/thr_concurrency.c,v 1.9 2004/12/18 18:07:37 deischen Exp $
  */
 #include <errno.h>
 #include <pthread.h>
@@ -84,6 +84,13 @@
 	int i;
 	int ret;
 
+	/*
+	 * Turn on threaded mode, if failed, it is unnecessary to
+	 * do further work.
+	 */
+	if (_kse_isthreaded() == 0 && _kse_setthreaded(1))
+		return (EAGAIN);
+
 	ret = 0;
 	curthread = _get_curthread();
 	/* Race condition, but so what. */

==== //depot/projects/wifi/lib/libpthread/thread/thr_cond.c#2 (text+ko) ====

@@ -29,7 +29,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/lib/libpthread/thread/thr_cond.c,v 1.51 2003/12/09 02:20:56 davidxu Exp $
+ * $FreeBSD: src/lib/libpthread/thread/thr_cond.c,v 1.52 2004/12/18 18:07:37 deischen Exp $
  */
 #include <stdlib.h>
 #include <errno.h>
@@ -47,6 +47,9 @@
 static inline struct pthread	*cond_queue_deq(pthread_cond_t);
 static inline void		cond_queue_remove(pthread_cond_t, pthread_t);
 static inline void		cond_queue_enq(pthread_cond_t, pthread_t);
+static void			cond_wait_backout(void *);
+static inline void		check_continuation(struct pthread *,
+				    struct pthread_cond *, pthread_mutex_t *);
 
 /*
  * Double underscore versions are cancellation points.  Single underscore
@@ -171,8 +174,7 @@
 	struct pthread	*curthread = _get_curthread();
 	int	rval = 0;
 	int	done = 0;
-	int	interrupted = 0;
-	int	unlock_mutex = 1;
+	int	mutex_locked = 1;
 	int	seqno;
 
 	if (cond == NULL)
@@ -198,10 +200,11 @@
 	 * and backed out of the waiting queue prior to executing the
 	 * signal handler.
 	 */
+
+	/* Lock the condition variable structure: */
+	THR_LOCK_ACQUIRE(curthread, &(*cond)->c_lock);
+	seqno = (*cond)->c_seqno;
 	do {
-		/* Lock the condition variable structure: */
-		THR_LOCK_ACQUIRE(curthread, &(*cond)->c_lock);
-
 		/*
 		 * If the condvar was statically allocated, properly
 		 * initialize the tail queue.
@@ -217,9 +220,6 @@
 		case COND_TYPE_FAST:
 			if ((mutex == NULL) || (((*cond)->c_mutex != NULL) &&
 			    ((*cond)->c_mutex != *mutex))) {
-				/* Unlock the condition variable structure: */
-				THR_LOCK_RELEASE(curthread, &(*cond)->c_lock);
-
 				/* Return invalid argument error: */
 				rval = EINVAL;
 			} else {
@@ -233,15 +233,11 @@
 				 */
 				cond_queue_enq(*cond, curthread);
 
-				/* Remember the mutex and sequence number: */
-				(*cond)->c_mutex = *mutex;
-				seqno = (*cond)->c_seqno;
-
 				/* Wait forever: */
 				curthread->wakeup_time.tv_sec = -1;
 
 				/* Unlock the mutex: */
-				if ((unlock_mutex != 0) &&
+				if (mutex_locked &&
 				    ((rval = _mutex_cv_unlock(mutex)) != 0)) {
 					/*
 					 * Cannot unlock the mutex, so remove
@@ -249,22 +245,18 @@
 					 * variable queue:
 					 */
 					cond_queue_remove(*cond, curthread);
-
-					/* Check for no more waiters: */
-					if (TAILQ_FIRST(&(*cond)->c_queue) == NULL)
-						(*cond)->c_mutex = NULL;
-
-					/* Unlock the condition variable structure: */
-					THR_LOCK_RELEASE(curthread, &(*cond)->c_lock);
 				}
 				else {
+					/* Remember the mutex: */
+					(*cond)->c_mutex = *mutex;
+
 					/*
 					 * Don't unlock the mutex the next
 					 * time through the loop (if the
 					 * thread has to be requeued after
 					 * handling a signal).
 					 */
-					unlock_mutex = 0;
+					mutex_locked = 0;
 
 					/*
 					 * This thread is active and is in a
@@ -277,6 +269,7 @@
 
 					/* Remember the CV: */
 					curthread->data.cond = *cond;
+					curthread->sigbackout = cond_wait_backout;
 					THR_SCHED_UNLOCK(curthread, curthread);
 
 					/* Unlock the CV structure: */
@@ -286,8 +279,6 @@
 					/* Schedule the next thread: */
 					_thr_sched_switch(curthread);
 
-					curthread->data.cond = NULL;
-
 					/*
 					 * XXX - This really isn't a good check
 					 * since there can be more than one
@@ -299,60 +290,61 @@
 					 * should be sent "as soon as possible".
 					 */
 					done = (seqno != (*cond)->c_seqno);
-
-					if (THR_IN_SYNCQ(curthread)) {
+					if (done && !THR_IN_CONDQ(curthread)) {
 						/*
-						 * Lock the condition variable
-						 * while removing the thread.
+						 * The thread is dequeued, so
+						 * it is safe to clear these.
 						 */
-						THR_LOCK_ACQUIRE(curthread,
-						    &(*cond)->c_lock);
+						curthread->data.cond = NULL;
+						curthread->sigbackout = NULL;
+						check_continuation(curthread,
+						    NULL, mutex);
+						return (_mutex_cv_lock(mutex));
+					}
+
+					/* Relock the CV structure: */
+					THR_LOCK_ACQUIRE(curthread,
+					    &(*cond)->c_lock);
+
+					/*
+					 * Clear these after taking the lock to
+					 * prevent a race condition where a
+					 * signal can arrive before dequeueing
+					 * the thread.
+					 */
+					curthread->data.cond = NULL;
+					curthread->sigbackout = NULL;
+					done = (seqno != (*cond)->c_seqno);
 
+					if (THR_IN_CONDQ(curthread)) {
 						cond_queue_remove(*cond,
 						    curthread);
 
 						/* Check for no more waiters: */
 						if (TAILQ_FIRST(&(*cond)->c_queue) == NULL)
 							(*cond)->c_mutex = NULL;
-
-						THR_LOCK_RELEASE(curthread,
-						    &(*cond)->c_lock);
 					}
-
-					/*
-					 * Save the interrupted flag; locking
-					 * the mutex may destroy it.
-					 */
-					interrupted = curthread->interrupted;
-
-					/*
-					 * Note that even though this thread may
-					 * have been canceled, POSIX requires
-					 * that the mutex be reaquired prior to
-					 * cancellation.
-					 */
-					if (done || interrupted) {
-						rval = _mutex_cv_lock(mutex);
-						unlock_mutex = 1;
-					}
 				}
 			}
 			break;
 
 		/* Trap invalid condition variable types: */
 		default:
-			/* Unlock the condition variable structure: */
-			THR_LOCK_RELEASE(curthread, &(*cond)->c_lock);
-
 			/* Return an invalid argument error: */
 			rval = EINVAL;
 			break;
 		}
 
-		if ((interrupted != 0) && (curthread->continuation != NULL))
-			curthread->continuation((void *) curthread);
+		check_continuation(curthread, *cond,
+		    mutex_locked ? NULL : mutex);
 	} while ((done == 0) && (rval == 0));
 
+	/* Unlock the condition variable structure: */
+	THR_LOCK_RELEASE(curthread, &(*cond)->c_lock);
+
+	if (mutex_locked == 0)
+		_mutex_cv_lock(mutex);
+
 	/* Return the completion status: */
 	return (rval);
 }
@@ -378,8 +370,7 @@
 	struct pthread	*curthread = _get_curthread();
 	int	rval = 0;
 	int	done = 0;
-	int	interrupted = 0;
-	int	unlock_mutex = 1;
+	int	mutex_locked = 1;
 	int	seqno;
 
 	THR_ASSERT(curthread->locklevel == 0,
@@ -407,10 +398,11 @@
 	 * and backed out of the waiting queue prior to executing the
 	 * signal handler.
 	 */
+
+	/* Lock the condition variable structure: */
+	THR_LOCK_ACQUIRE(curthread, &(*cond)->c_lock);
+	seqno = (*cond)->c_seqno;
 	do {
-		/* Lock the condition variable structure: */
-		THR_LOCK_ACQUIRE(curthread, &(*cond)->c_lock);
-
 		/*
 		 * If the condvar was statically allocated, properly
 		 * initialize the tail queue.
@@ -428,9 +420,6 @@
 			    ((*cond)->c_mutex != *mutex))) {
 				/* Return invalid argument error: */
 				rval = EINVAL;
-
-				/* Unlock the condition variable structure: */
-				THR_LOCK_RELEASE(curthread, &(*cond)->c_lock);
 			} else {
 				/* Set the wakeup time: */
 				curthread->wakeup_time.tv_sec = abstime->tv_sec;
@@ -447,12 +436,8 @@
 				 */
 				cond_queue_enq(*cond, curthread);
 
-				/* Remember the mutex and sequence number: */
-				(*cond)->c_mutex = *mutex;
-				seqno = (*cond)->c_seqno;
-
 				/* Unlock the mutex: */
-				if ((unlock_mutex != 0) &&
+				if (mutex_locked &&
 				   ((rval = _mutex_cv_unlock(mutex)) != 0)) {
 					/*
 					 * Cannot unlock the mutex; remove the
@@ -460,21 +445,17 @@
 					 * variable queue: 
 					 */
 					cond_queue_remove(*cond, curthread);
-
-					/* Check for no more waiters: */
-					if (TAILQ_FIRST(&(*cond)->c_queue) == NULL)
-						(*cond)->c_mutex = NULL;
+				} else {
+					/* Remember the mutex: */
+					(*cond)->c_mutex = *mutex;
 
-					/* Unlock the condition variable structure: */
-					THR_LOCK_RELEASE(curthread, &(*cond)->c_lock);
-				} else {
 					/*
 					 * Don't unlock the mutex the next
 					 * time through the loop (if the
 					 * thread has to be requeued after
 					 * handling a signal).
 					 */
-					unlock_mutex = 0;
+					mutex_locked = 0;
 
 					/*
 					 * This thread is active and is in a
@@ -487,6 +468,7 @@
 
 					/* Remember the CV: */
 					curthread->data.cond = *cond;
+					curthread->sigbackout = cond_wait_backout;
 					THR_SCHED_UNLOCK(curthread, curthread);
 
 					/* Unlock the CV structure: */
@@ -496,8 +478,6 @@
 					/* Schedule the next thread: */
 					_thr_sched_switch(curthread);
 
-					curthread->data.cond = NULL;
-
 					/*
 					 * XXX - This really isn't a good check
 					 * since there can be more than one
@@ -509,38 +489,45 @@
 					 * should be sent "as soon as possible".
 					 */
 					done = (seqno != (*cond)->c_seqno);
-
-					if (THR_IN_CONDQ(curthread)) {
+					if (done && !THR_IN_CONDQ(curthread)) {
 						/*
-						 * Lock the condition variable
-						 * while removing the thread.
+						 * The thread is dequeued, so
+						 * it is safe to clear these.
 						 */
-						THR_LOCK_ACQUIRE(curthread,
-						    &(*cond)->c_lock);
+						curthread->data.cond = NULL;
+						curthread->sigbackout = NULL;
+						check_continuation(curthread,
+						    NULL, mutex);
+						return (_mutex_cv_lock(mutex));
+					}
+
+					/* Relock the CV structure: */
+					THR_LOCK_ACQUIRE(curthread,
+					    &(*cond)->c_lock);
+
+					/*
+					 * Clear these after taking the lock to
+					 * prevent a race condition where a
+					 * signal can arrive before dequeueing
+					 * the thread.
+					 */
+					curthread->data.cond = NULL;
+					curthread->sigbackout = NULL;
+
+					done = (seqno != (*cond)->c_seqno);
 
+					if (THR_IN_CONDQ(curthread)) {
 						cond_queue_remove(*cond,
 						    curthread);
 
 						/* Check for no more waiters: */
 						if (TAILQ_FIRST(&(*cond)->c_queue) == NULL)
 							(*cond)->c_mutex = NULL;
-
-						THR_LOCK_RELEASE(curthread,
-						    &(*cond)->c_lock);
 					}
 
-					/*
-					 * Save the interrupted flag; locking
-					 * the mutex may destroy it.
-					 */
-					interrupted = curthread->interrupted;
 					if (curthread->timeout != 0) {
 						/* The wait timedout. */
 						rval = ETIMEDOUT;
-						(void)_mutex_cv_lock(mutex);
-					} else if (interrupted || done) {
-						rval = _mutex_cv_lock(mutex);
-						unlock_mutex = 1;
 					}
 				}
 			}
@@ -548,18 +535,21 @@
 
 		/* Trap invalid condition variable types: */
 		default:
-			/* Unlock the condition variable structure: */
-			THR_LOCK_RELEASE(curthread, &(*cond)->c_lock);
-
 			/* Return an invalid argument error: */
 			rval = EINVAL;
 			break;
 		}
 
-		if ((interrupted != 0) && (curthread->continuation != NULL))
-			curthread->continuation((void *)curthread);
+		check_continuation(curthread, *cond,
+		    mutex_locked ? NULL : mutex);
 	} while ((done == 0) && (rval == 0));
 
+	/* Unlock the condition variable structure: */
+	THR_LOCK_RELEASE(curthread, &(*cond)->c_lock);
+
+	if (mutex_locked == 0)
+		_mutex_cv_lock(mutex);
+
 	/* Return the completion status: */
 	return (rval);
 }
@@ -615,6 +605,7 @@
 			    != NULL) {
 				THR_SCHED_LOCK(curthread, pthread);
 				cond_queue_remove(*cond, pthread);
+				pthread->sigbackout = NULL;
 				if ((pthread->kseg == curthread->kseg) &&
 				    (pthread->active_priority >
 				    curthread->active_priority))
@@ -681,6 +672,7 @@
 			    != NULL) {
 				THR_SCHED_LOCK(curthread, pthread);
 				cond_queue_remove(*cond, pthread);
+				pthread->sigbackout = NULL;
 				if ((pthread->kseg == curthread->kseg) &&
 				    (pthread->active_priority >
 				    curthread->active_priority))
@@ -712,9 +704,31 @@
 
 __strong_reference(_pthread_cond_broadcast, _thr_cond_broadcast);
 
-void
-_cond_wait_backout(struct pthread *curthread)
+static inline void
+check_continuation(struct pthread *curthread, struct pthread_cond *cond,
+    pthread_mutex_t *mutex)
+{
+	if ((curthread->interrupted != 0) &&
+	    (curthread->continuation != NULL)) {
+		if (cond != NULL)
+			/* Unlock the condition variable structure: */
+			THR_LOCK_RELEASE(curthread, &cond->c_lock);
+		/*
+		 * Note that even though this thread may have been
+		 * canceled, POSIX requires that the mutex be
+		 * reaquired prior to cancellation.
+		 */
+		if (mutex != NULL)
+			_mutex_cv_lock(mutex);
+		curthread->continuation((void *) curthread);
+		PANIC("continuation returned in pthread_cond_wait.\n");
+	}
+}
+
+static void
+cond_wait_backout(void *arg)
 {
+	struct pthread *curthread = (struct pthread *)arg;
 	pthread_cond_t	cond;
 
 	cond = curthread->data.cond;
@@ -740,6 +754,8 @@
 		/* Unlock the condition variable structure: */
 		THR_LOCK_RELEASE(curthread, &cond->c_lock);
 	}
+	/* No need to call this again. */
+	curthread->sigbackout = NULL;
 }
 
 /*

==== //depot/projects/wifi/lib/libpthread/thread/thr_create.c#2 (text+ko) ====

@@ -30,7 +30,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/lib/libpthread/thread/thr_create.c,v 1.58 2004/10/23 23:28:36 davidxu Exp $
+ * $FreeBSD: src/lib/libpthread/thread/thr_create.c,v 1.59 2004/12/18 18:07:37 deischen Exp $
  */
 #include <errno.h>
 #include <stdlib.h>
@@ -171,9 +171,6 @@
 			/* No thread is wanting to join to this one: */
 			new_thread->joiner = NULL;
 
-			/* Initialize the signal frame: */
-			new_thread->curframe = NULL;
-
 			/*
 			 * Initialize the machine context.
 			 * Enter a critical region to get consistent context.
@@ -235,6 +232,7 @@
 			new_thread->cleanup = NULL;
 			new_thread->flags = 0;
 			new_thread->tlflags = 0;
+			new_thread->sigbackout = NULL;
 			new_thread->continuation = NULL;
 			new_thread->wakeup_time.tv_sec = -1;
 			new_thread->lock_switch = 0;

==== //depot/projects/wifi/lib/libpthread/thread/thr_fork.c#2 (text+ko) ====

@@ -29,7 +29,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/lib/libpthread/thread/thr_fork.c,v 1.34 2003/11/05 18:18:45 deischen Exp $
+ * $FreeBSD: src/lib/libpthread/thread/thr_fork.c,v 1.35 2004/12/18 18:07:37 deischen Exp $
  */
 #include <errno.h>
 #include <string.h>
@@ -43,12 +43,6 @@
 #include "libc_private.h"
 #include "thr_private.h"
 
-/*
- * For a while, allow libpthread to work with a libc that doesn't
- * export the malloc lock.
- */
-#pragma weak __malloc_lock
-
 __weak_reference(_fork, fork);
 
 pid_t
@@ -60,10 +54,20 @@
 	pid_t ret;
 	int errsave;
 
-	if (!_kse_isthreaded())
-		return (__sys_fork());
+	curthread = _get_curthread();
 
-	curthread = _get_curthread();
+	if (!_kse_isthreaded()) {
+		SIGFILLSET(sigset);
+		__sys_sigprocmask(SIG_SETMASK, &sigset, &oldset);
+		ret = __sys_fork();
+		if (ret == 0)
+			/* Child */
+			__sys_sigprocmask(SIG_SETMASK, &curthread->sigmask,
+			    NULL);
+		else
+			__sys_sigprocmask(SIG_SETMASK, &oldset, NULL);
+		return (ret);
+	}
 
 	/*
 	 * Masks all signals until we reach a safe point in
@@ -86,7 +90,7 @@
 	}
 
 	/* Fork a new process: */
-	if ((_kse_isthreaded() != 0) && (__malloc_lock != NULL)) {
+	if (_kse_isthreaded() != 0) {
 		_spinlock(__malloc_lock);
 	}
 	if ((ret = __sys_fork()) == 0) {

==== //depot/projects/wifi/lib/libpthread/thread/thr_init.c#2 (text+ko) ====

@@ -30,7 +30,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/lib/libpthread/thread/thr_init.c,v 1.66 2004/08/21 11:49:19 davidxu Exp $
+ * $FreeBSD: src/lib/libpthread/thread/thr_init.c,v 1.67 2004/12/18 18:07:37 deischen Exp $
  */
 
 /* Allocate space for global thread variables here: */
@@ -391,6 +391,7 @@
 	thread->specific = NULL;
 	thread->cleanup = NULL;
 	thread->flags = 0;
+	thread->sigbackout = NULL;
 	thread->continuation = NULL;
 
 	thread->state = PS_RUNNING;

==== //depot/projects/wifi/lib/libpthread/thread/thr_kern.c#2 (text+ko) ====

@@ -33,7 +33,7 @@
  *

>>> TRUNCATED FOR MAIL (1000 lines) <<<


More information about the p4-projects mailing list