diff options
author | mtm <mtm@FreeBSD.org> | 2003-05-25 22:40:57 +0000 |
---|---|---|
committer | mtm <mtm@FreeBSD.org> | 2003-05-25 22:40:57 +0000 |
commit | d8e0ed54e351db48278bd6693dde605fcda057df (patch) | |
tree | 8bc5a970789c8f2762484249a02b9ccd0ccb6ef6 /lib/libthr/thread/thr_create.c | |
parent | 54155a49a5a2b84f07b579c8e6af7e5f9c8e1d88 (diff) | |
download | FreeBSD-src-d8e0ed54e351db48278bd6693dde605fcda057df.zip FreeBSD-src-d8e0ed54e351db48278bd6693dde605fcda057df.tar.gz |
Return gracefully, rather than aborting, when the maximum concurrent
threads per process has been reached. Return EAGAIN, as per spec.
Approved by: re/blanket libthr
Diffstat (limited to 'lib/libthr/thread/thr_create.c')
-rw-r--r-- | lib/libthr/thread/thr_create.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/libthr/thread/thr_create.c b/lib/libthr/thread/thr_create.c index 3033421..5b0158d 100644 --- a/lib/libthr/thread/thr_create.c +++ b/lib/libthr/thread/thr_create.c @@ -116,7 +116,18 @@ _pthread_create(pthread_t * thread, const pthread_attr_t * attr, new_thread->ctx.uc_stack.ss_sp = new_thread->stack; new_thread->ctx.uc_stack.ss_size = pattr->stacksize_attr; makecontext(&new_thread->ctx, _thread_start, 0); - new_thread->arch_id = _set_curthread(&new_thread->ctx, new_thread); + new_thread->arch_id = _set_curthread(&new_thread->ctx, new_thread, &ret); + if (ret != 0) { + if (pattr->stackaddr_attr == NULL) { + /* XXX - We really need to decouple from this lock */ + DEAD_LIST_LOCK; + _thread_stack_free(new_thread->stack, + pattr->stacksize_attr, pattr->guardsize_attr); + DEAD_LIST_UNLOCK; + } + free(new_thread); + return (ret); + } /* Copy the thread attributes: */ memcpy(&new_thread->attr, pattr, sizeof(struct pthread_attr)); |