diff options
author | Ted Unangst <tedu@cvs.openbsd.org> | 2005-12-23 03:27:07 +0000 |
---|---|---|
committer | Ted Unangst <tedu@cvs.openbsd.org> | 2005-12-23 03:27:07 +0000 |
commit | 99a150e4e9774323e933d9a0c08fea7bed16b994 (patch) | |
tree | 4f672d62d2e9db7e34ebacab5d9c95f668eae048 /lib/librthread | |
parent | e33101d8f40306fbe619ee9631020b4b814204bb (diff) |
for reasons that do not make any sense whatsoever, _rthread_alloc_stack
must be called with the thread_lock held, or we crash in rfork_thread
Diffstat (limited to 'lib/librthread')
-rw-r--r-- | lib/librthread/rthread.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/lib/librthread/rthread.c b/lib/librthread/rthread.c index 45cc51e5416..c4e1e502d0d 100644 --- a/lib/librthread/rthread.c +++ b/lib/librthread/rthread.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rthread.c,v 1.17 2005/12/22 06:49:48 tedu Exp $ */ +/* $OpenBSD: rthread.c,v 1.18 2005/12/23 03:27:06 tedu Exp $ */ /* * Copyright (c) 2004,2005 Ted Unangst <tedu@openbsd.org> * All Rights Reserved. @@ -232,18 +232,17 @@ pthread_create(pthread_t *threadp, const pthread_attr_t *attr, if (!thread) return (errno); memset(thread, 0, sizeof(*thread)); - thread->stack = _rthread_alloc_stack(64 * 1024, NULL); - if (!thread->stack) { - rc = errno; - goto fail1; - } - thread->donesem.lock = _SPINLOCK_UNLOCKED; thread->fn = start_routine; thread->arg = arg; _spinlock(&thread_lock); + thread->stack = _rthread_alloc_stack(64 * 1024, NULL); + if (!thread->stack) { + rc = errno; + goto fail1; + } thread->next = thread_list; thread_list = thread; @@ -258,13 +257,14 @@ pthread_create(pthread_t *threadp, const pthread_attr_t *attr, thread->flags |= THREAD_CANCEL_ENABLE|THREAD_CANCEL_DEFERRED; *threadp = thread; _spinunlock(&thread_lock); + return (0); fail2: - thread_list = thread->next; - _spinunlock(&thread_lock); _rthread_free_stack(thread->stack); fail1: + thread_list = thread->next; + _spinunlock(&thread_lock); free(thread); return (rc); |