Fix in error handling in pthread_create.cpp.

It is due to a previous change "Let g_thread_list_lock only protect g_thread_list".
We need to add the newly created thread to thread_list even if
__init_thread fails, so the thread can exit successfully.

Change-Id: I0332df11acfdd181350bcc092b12d90d679057a4
This commit is contained in:
Yabin Cui 2015-03-25 16:18:21 -07:00
parent 0c3b632bd6
commit 799cb35f45

View File

@ -267,6 +267,7 @@ int pthread_create(pthread_t* thread_out, pthread_attr_t const* attr,
// Mark the thread detached and replace its start_routine with a no-op.
// Letting the thread run is the easiest way to clean up its resources.
atomic_store(&thread->join_state, THREAD_DETACHED);
__pthread_internal_add(thread);
thread->start_routine = __do_nothing;
pthread_mutex_unlock(&thread->startup_handshake_mutex);
return init_errno;