sched/pthread: check pthread group after find joininfo
Need check tcb or group info after find joininfo, otherwise the wrong value will be returned. Signed-off-by: zhangyuan21 <zhangyuan21@xiaomi.com>
This commit is contained in:
parent
8f4cb0fec3
commit
9017f70561
|
@ -141,7 +141,8 @@ FAR struct join_s *pthread_findjoininfo(FAR struct task_group_s *group,
|
|||
FAR struct tcb_s *tcb = nxsched_get_tcb((pthread_t)pid);
|
||||
|
||||
if (tcb != NULL && (tcb->flags & TCB_FLAG_DETACHED) == 0 &&
|
||||
(tcb->flags & TCB_FLAG_TTYPE_MASK) == TCB_FLAG_TTYPE_PTHREAD)
|
||||
(tcb->flags & TCB_FLAG_TTYPE_MASK) == TCB_FLAG_TTYPE_PTHREAD &&
|
||||
tcb->group == group)
|
||||
{
|
||||
pjoin = pthread_createjoininfo((FAR struct pthread_tcb_s *)tcb);
|
||||
}
|
||||
|
|
|
@ -75,7 +75,6 @@ int pthread_join(pthread_t thread, FAR pthread_addr_t *pexit_value)
|
|||
FAR struct tcb_s *rtcb = this_task();
|
||||
FAR struct task_group_s *group = rtcb->group;
|
||||
FAR struct join_s *pjoin;
|
||||
FAR struct tcb_s *tcb;
|
||||
int ret;
|
||||
|
||||
sinfo("thread=%d group=%p\n", thread, group);
|
||||
|
@ -85,18 +84,11 @@ int pthread_join(pthread_t thread, FAR pthread_addr_t *pexit_value)
|
|||
|
||||
enter_cancellation_point();
|
||||
|
||||
tcb = nxsched_get_tcb(thread);
|
||||
if (tcb != NULL && tcb->group != group)
|
||||
{
|
||||
leave_cancellation_point();
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
/* First make sure that this is not an attempt to join to
|
||||
* ourself.
|
||||
*/
|
||||
|
||||
if (tcb == rtcb)
|
||||
if ((pid_t)thread == gettid())
|
||||
{
|
||||
leave_cancellation_point();
|
||||
return EDEADLK;
|
||||
|
@ -122,6 +114,8 @@ int pthread_join(pthread_t thread, FAR pthread_addr_t *pexit_value)
|
|||
{
|
||||
/* Determine what kind of error to return */
|
||||
|
||||
FAR struct tcb_s *tcb = nxsched_get_tcb((pthread_t)thread);
|
||||
|
||||
swarn("WARNING: Could not find thread data\n");
|
||||
|
||||
/* Case (1) or (3) -- we can't tell which. Assume (3) */
|
||||
|
|
Loading…
Reference in New Issue