mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-26 06:50:07 +00:00
(__pthread_create_2_1): Remember whether thread is created detached and if yes, do not try to free the stack in case the thread creation failed.
This commit is contained in:
parent
24f076f84e
commit
ebfa58bb23
@ -447,12 +447,18 @@ __pthread_create_2_1 (newthread, attr, start_routine, arg)
|
|||||||
/* Pass the descriptor to the caller. */
|
/* Pass the descriptor to the caller. */
|
||||||
*newthread = (pthread_t) pd;
|
*newthread = (pthread_t) pd;
|
||||||
|
|
||||||
|
/* Remember whether the thread is detached or not. In case of an
|
||||||
|
error we have to free the stacks of non-detached stillborn
|
||||||
|
threads. */
|
||||||
|
bool is_detached = IS_DETACHED (pd);
|
||||||
|
|
||||||
/* Start the thread. */
|
/* Start the thread. */
|
||||||
err = create_thread (pd, iattr, STACK_VARIABLES_ARGS);
|
err = create_thread (pd, iattr, STACK_VARIABLES_ARGS);
|
||||||
if (err != 0)
|
if (err != 0)
|
||||||
{
|
{
|
||||||
errout:
|
errout:
|
||||||
/* Something went wrong. Free the resources. */
|
/* Something went wrong. Free the resources. */
|
||||||
|
if (!is_detached)
|
||||||
__deallocate_stack (pd);
|
__deallocate_stack (pd);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user