mirror of
https://github.com/apache/nuttx.git
synced 2026-05-27 19:36:35 +08:00
Group binding needs to be cleared before sched_releasetcb(), as otherwise group_leave() will be called and group->tg_nmembers decremented or group being released. group_leave() should be called only after group_join() is called, not after group_bind(). From Jussi Kivilinna.
This commit is contained in:
committed by
Gregory Nutt
parent
464390193e
commit
13d9383679
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* sched/pthread/pthread_create.c
|
* sched/pthread/pthread_create.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007-2009, 2011, 2013-2014 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2007-2009, 2011, 2013-2015 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -241,6 +241,9 @@ int pthread_create(FAR pthread_t *thread, FAR const pthread_attr_t *attr,
|
|||||||
int errcode;
|
int errcode;
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
int ret;
|
int ret;
|
||||||
|
#ifdef HAVE_TASK_GROUP
|
||||||
|
bool group_joined = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* If attributes were not supplied, use the default attributes */
|
/* If attributes were not supplied, use the default attributes */
|
||||||
|
|
||||||
@@ -368,6 +371,8 @@ int pthread_create(FAR pthread_t *thread, FAR const pthread_attr_t *attr,
|
|||||||
errcode = ENOMEM;
|
errcode = ENOMEM;
|
||||||
goto errout_with_join;
|
goto errout_with_join;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
group_joined = true;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Attach the join info to the TCB. */
|
/* Attach the join info to the TCB. */
|
||||||
@@ -451,6 +456,15 @@ errout_with_join:
|
|||||||
ptcb->joininfo = NULL;
|
ptcb->joininfo = NULL;
|
||||||
|
|
||||||
errout_with_tcb:
|
errout_with_tcb:
|
||||||
|
#ifdef HAVE_TASK_GROUP
|
||||||
|
/* Clear group binding */
|
||||||
|
|
||||||
|
if (ptcb && !group_joined)
|
||||||
|
{
|
||||||
|
ptcb->cmn.group = NULL;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
sched_releasetcb((FAR struct tcb_s *)ptcb, TCB_FLAG_TTYPE_PTHREAD);
|
sched_releasetcb((FAR struct tcb_s *)ptcb, TCB_FLAG_TTYPE_PTHREAD);
|
||||||
return errcode;
|
return errcode;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user