diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2012-02-16 20:55:10 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2012-02-16 20:55:10 +0000 |
commit | 4c9526692717e1c85a770f56ccfbc79b58d4b2ac (patch) | |
tree | e88cc237c63e683d27e6333adb12b5f858b3448e /lib/librthread/rthread.c | |
parent | 51783b3f5876a270462816ab2bd0273d09406c4c (diff) |
Set __isthreaded in pthread_create() instead of _rthread_init() such that it
properly represents whether a process is multi-threaded or not. This fixes
a bug where if a forked child would create a new thread we would not set
__isthreaded.
ok guenther@
Diffstat (limited to 'lib/librthread/rthread.c')
-rw-r--r-- | lib/librthread/rthread.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/librthread/rthread.c b/lib/librthread/rthread.c index 8f761c3896d..eeae528d57f 100644 --- a/lib/librthread/rthread.c +++ b/lib/librthread/rthread.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rthread.c,v 1.50 2012/01/17 02:34:18 guenther Exp $ */ +/* $OpenBSD: rthread.c,v 1.51 2012/02/16 20:55:09 kettenis Exp $ */ /* * Copyright (c) 2004,2005 Ted Unangst <tedu@openbsd.org> * All Rights Reserved. @@ -135,7 +135,6 @@ static int _rthread_init(void) { pthread_t thread = &_initial_thread; - extern int __isthreaded; struct sigaction sa; thread->tid = getthrid(); @@ -147,7 +146,6 @@ _rthread_init(void) _rthread_debug_init(); _threads_ready = 1; - __isthreaded = 1; _rthread_debug(1, "rthread init\n"); @@ -353,6 +351,7 @@ int pthread_create(pthread_t *threadp, const pthread_attr_t *attr, void *(*start_routine)(void *), void *arg) { + extern int __isthreaded; struct thread_control_block *tcb; pthread_t thread; struct __tfork param; @@ -405,6 +404,8 @@ pthread_create(pthread_t *threadp, const pthread_attr_t *attr, LIST_INSERT_HEAD(&_thread_list, thread, threads); _spinunlock(&_thread_lock); + /* we're going to be multi-threaded real soon now */ + __isthreaded = 1; rc = __tfork_thread(¶m, thread->stack->sp, _rthread_start, thread); if (rc != -1) { /* success */ |