diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2013-02-26 00:56:59 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2013-02-26 00:56:59 +0000 |
commit | 16b331cdc8d014264d17099f7034e45fca0bd7a8 (patch) | |
tree | 7cf6ab24b9e0d8c17f3df339eb82c1c74dcfd736 /nuttx/sched/group_leave.c | |
parent | 2839e79985e189fdbe5f1ab1d7229369aa70072b (diff) | |
download | px4-nuttx-16b331cdc8d014264d17099f7034e45fca0bd7a8.tar.gz px4-nuttx-16b331cdc8d014264d17099f7034e45fca0bd7a8.tar.bz2 px4-nuttx-16b331cdc8d014264d17099f7034e45fca0bd7a8.zip |
Minor changes to make OS test more robust in the presence of many memory allocation failures
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5672 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/sched/group_leave.c')
-rw-r--r-- | nuttx/sched/group_leave.c | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/nuttx/sched/group_leave.c b/nuttx/sched/group_leave.c index 490a66ec0..44c52a56d 100644 --- a/nuttx/sched/group_leave.c +++ b/nuttx/sched/group_leave.c @@ -245,7 +245,7 @@ static inline void group_release(FAR struct task_group_s *group) *****************************************************************************/ #ifdef HAVE_GROUP_MEMBERS -static inline int group_removemember(FAR struct task_group_s *group, pid_t pid) +static inline void group_removemember(FAR struct task_group_s *group, pid_t pid) { irqstate_t flags; int i; @@ -269,12 +269,8 @@ static inline int group_removemember(FAR struct task_group_s *group, pid_t pid) group->tg_members[i] = group->tg_members[group->tg_nmembers - 1]; group->tg_nmembers--; irqrestore(flags); - - return group->tg_nmembers; } } - - return -ENOENT; } #endif /* HAVE_GROUP_MEMBERS */ @@ -310,21 +306,24 @@ void group_leave(FAR struct tcb_s *tcb) DEBUGASSERT(tcb); - /* Make sure that we have a group */ + /* Make sure that we have a group. */ group = tcb->group; if (group) { - /* Remove the member from group */ + /* Remove the member from group. This function may be called + * during certain error handling before the PID has been + * added to the group. In this case tcb->pid will be uninitialized + * group_removemember() will fail. + */ - int ret = group_removemember(group, tcb->pid); - DEBUGASSERT(ret >= 0); + group_removemember(group, tcb->pid); - /* Is the group now empty? */ + /* Have all of the members left the group? */ - if (ret == 0) + if (group->tg_nmembers == 0) { - /* Release all of the resource held by the task group */ + /* Yes.. Release all of the resource held by the task group */ group_release(group); } |