diff options
| author | Daniel Eischen <deischen@FreeBSD.org> | 2003-04-22 20:28:33 +0000 |
|---|---|---|
| committer | Daniel Eischen <deischen@FreeBSD.org> | 2003-04-22 20:28:33 +0000 |
| commit | 6dee371a559db5d6bce5e827e6addf9b52bd4a0e (patch) | |
| tree | 19f3d1be5afa27ed30120ee055e1c276564167d9 /lib/libpthread/thread/thr_create.c | |
| parent | 897ecacd6488f80e815b6be7188c145335a5bcba (diff) | |
Notes
Diffstat (limited to 'lib/libpthread/thread/thr_create.c')
| -rw-r--r-- | lib/libpthread/thread/thr_create.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/lib/libpthread/thread/thr_create.c b/lib/libpthread/thread/thr_create.c index c38b26746eab..deb26de438d9 100644 --- a/lib/libpthread/thread/thr_create.c +++ b/lib/libpthread/thread/thr_create.c @@ -57,6 +57,7 @@ int _thread_ctx_offset = OFF(tmbx.tm_context); int _thread_PS_RUNNING_value = PS_RUNNING; int _thread_PS_DEAD_value = PS_DEAD; +static void free_thread(struct pthread *curthread, struct pthread *thread); static int create_stack(struct pthread_attr *pattr); static void thread_start(struct pthread *curthread, void *(*start_routine) (void *), void *arg); @@ -295,8 +296,10 @@ _pthread_create(pthread_t * thread, const pthread_attr_t * attr, * Schedule the new thread starting a new KSEG/KSE * pair if necessary. */ - _thr_schedule_add(curthread, new_thread); + ret = _thr_schedule_add(curthread, new_thread); _kse_critical_leave(crit); + if (ret != 0) + free_thread(curthread, new_thread); /* Return a pointer to the thread structure: */ (*thread) = new_thread; @@ -307,6 +310,17 @@ _pthread_create(pthread_t * thread, const pthread_attr_t * attr, return (ret); } +static void +free_thread(struct pthread *curthread, struct pthread *thread) +{ + if ((thread->attr.flags & PTHREAD_SCOPE_SYSTEM) != 0) { + /* Free the KSE and KSEG. */ + _kseg_free(thread->kseg); + _kse_free(curthread, thread->kse); + } + _thr_free(curthread, thread); +} + static int create_stack(struct pthread_attr *pattr) { |
