From dc39f9ec83784d35bc75dc9d9a7461b6cbdffefe Mon Sep 17 00:00:00 2001 From: ad Date: Fri, 2 Mar 2007 17:40:55 +0000 Subject: pthread_detach: acquire the join lock before changing pt_flags. --- lib/libpthread/pthread.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'lib/libpthread') diff --git a/lib/libpthread/pthread.c b/lib/libpthread/pthread.c index fdf2bd4329f..8419853a6ff 100644 --- a/lib/libpthread/pthread.c +++ b/lib/libpthread/pthread.c @@ -1,4 +1,4 @@ -/* $NetBSD: pthread.c,v 1.62 2007/02/21 22:31:38 ad Exp $ */ +/* $NetBSD: pthread.c,v 1.63 2007/03/02 17:40:55 ad Exp $ */ /*- * Copyright (c) 2001, 2002, 2003, 2006, 2007 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include -__RCSID("$NetBSD: pthread.c,v 1.62 2007/02/21 22:31:38 ad Exp $"); +__RCSID("$NetBSD: pthread.c,v 1.63 2007/03/02 17:40:55 ad Exp $"); #include #include @@ -69,7 +69,7 @@ __RCSID("$NetBSD: pthread.c,v 1.62 2007/02/21 22:31:38 ad Exp $"); #define PTHREAD__UNPARK_MAX 128 /* How many times to try acquiring spin locks on MP systems. */ -#define PTHREAD__NSPINS 1000 +#define PTHREAD__NSPINS 1024 static void pthread__create_tramp(void *(*start)(void *), void *arg); static void pthread__dead(pthread_t, pthread_t); @@ -943,7 +943,9 @@ pthread_detach(pthread_t thread) return 0; #else + pthread_spinlock(self, &self->pt_join_lock); thread->pt_flags |= PT_FLAG_DETACHED; + pthread_spinunlock(self, &self->pt_join_lock); return _lwp_detach(thread->pt_lid); #endif } -- cgit