The mutex of a thread has to be locked when destroying it.

This commit is contained in:
Tobias Brunner 2010-04-29 13:30:51 +02:00
parent 257e27df07
commit 361f416d2c
1 changed files with 2 additions and 0 deletions

View File

@ -300,6 +300,7 @@ thread_t *thread_create(thread_main_t main, void *arg)
if (pthread_create(&this->thread_id, NULL, (void*)thread_main, this) != 0)
{
DBG1(DBG_LIB, "failed to create thread!");
this->mutex->lock(this->mutex);
thread_destroy(this);
return NULL;
}
@ -433,6 +434,7 @@ void threads_init()
void threads_deinit()
{
private_thread_t *main_thread = (private_thread_t*)thread_current();
main_thread->mutex->lock(main_thread->mutex);
thread_destroy(main_thread);
current_thread->destroy(current_thread);
id_mutex->destroy(id_mutex);