Skip to content
Snippets Groups Projects
Commit 13d93836 authored by Jussi Kivilinna's avatar Jussi Kivilinna Committed by Gregory Nutt
Browse files

Group binding needs to be cleared before sched_releasetcb(), as otherwise...

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.
parent 46439019
No related branches found
No related tags found
No related merge requests found
/****************************************************************************
* 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>
*
* 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;
pid_t pid;
int ret;
#ifdef HAVE_TASK_GROUP
bool group_joined = false;
#endif
/* 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;
goto errout_with_join;
}
group_joined = true;
#endif
/* Attach the join info to the TCB. */
......@@ -451,6 +456,15 @@ errout_with_join:
ptcb->joininfo = NULL;
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);
return errcode;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment