diff options
| author | Daniel Eischen <deischen@FreeBSD.org> | 2005-08-30 12:42:00 +0000 |
|---|---|---|
| committer | Daniel Eischen <deischen@FreeBSD.org> | 2005-08-30 12:42:00 +0000 |
| commit | f98418eb2941434d2d73cd803787faa5015854b7 (patch) | |
| tree | c87b833ab649a3dbefbf6b57732337659cee2503 /lib/libpthread/thread | |
| parent | bb78dba49b79cf66f84c863e3c392ba9f9b7f08d (diff) | |
Notes
Diffstat (limited to 'lib/libpthread/thread')
| -rw-r--r-- | lib/libpthread/thread/thr_kern.c | 41 |
1 files changed, 21 insertions, 20 deletions
diff --git a/lib/libpthread/thread/thr_kern.c b/lib/libpthread/thread/thr_kern.c index 85d9b33fafa3..d57665e89a9c 100644 --- a/lib/libpthread/thread/thr_kern.c +++ b/lib/libpthread/thread/thr_kern.c @@ -2365,6 +2365,11 @@ _thr_alloc(struct pthread *curthread) if ((thread == NULL) && ((thread = malloc(sizeof(struct pthread))) != NULL)) { bzero(thread, sizeof(struct pthread)); + thread->siginfo = calloc(_SIG_MAXSIG, sizeof(siginfo_t)); + if (thread->siginfo == NULL) { + free(thread); + return (NULL); + } if (curthread) { _pthread_mutex_lock(&_tcb_mutex); thread->tcb = _tcb_ctor(thread, 0 /* not initial tls */); @@ -2372,27 +2377,23 @@ _thr_alloc(struct pthread *curthread) } else { thread->tcb = _tcb_ctor(thread, 1 /* initial tls */); } - thread->siginfo = calloc(_SIG_MAXSIG, sizeof(siginfo_t)); - if ((thread->tcb == NULL) || (thread->siginfo == NULL)) { - if (thread->siginfo != NULL) - free(thread->siginfo); + if (thread->tcb == NULL) { + free(thread->siginfo); free(thread); - thread = NULL; - } else { - /* - * Initialize thread locking. - * Lock initializing needs malloc, so don't - * enter critical region before doing this! - */ - if (_lock_init(&thread->lock, LCK_ADAPTIVE, - _thr_lock_wait, _thr_lock_wakeup) != 0) - PANIC("Cannot initialize thread lock"); - for (i = 0; i < MAX_THR_LOCKLEVEL; i++) { - _lockuser_init(&thread->lockusers[i], - (void *)thread); - _LCK_SET_PRIVATE2(&thread->lockusers[i], - (void *)thread); - } + return (NULL); + } + /* + * Initialize thread locking. + * Lock initializing needs malloc, so don't + * enter critical region before doing this! + */ + if (_lock_init(&thread->lock, LCK_ADAPTIVE, + _thr_lock_wait, _thr_lock_wakeup) != 0) + PANIC("Cannot initialize thread lock"); + for (i = 0; i < MAX_THR_LOCKLEVEL; i++) { + _lockuser_init(&thread->lockusers[i], (void *)thread); + _LCK_SET_PRIVATE2(&thread->lockusers[i], + (void *)thread); } } return (thread); |
