summaryrefslogtreecommitdiff
path: root/nuttx/sched/task_exithook.c
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-04-23 13:59:31 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-04-23 13:59:31 +0000
commit68bc7cefbd11c4dbeca86fb64fac3466dd4f5b69 (patch)
treefd1605d23bc93e70f2d8bd7fa5541bec9d33cd2d /nuttx/sched/task_exithook.c
parentcc17fe8980154e5af111651cce271798b4f8482b (diff)
downloadpx4-nuttx-68bc7cefbd11c4dbeca86fb64fac3466dd4f5b69.tar.gz
px4-nuttx-68bc7cefbd11c4dbeca86fb64fac3466dd4f5b69.tar.bz2
px4-nuttx-68bc7cefbd11c4dbeca86fb64fac3466dd4f5b69.zip
Fix atexit() function being called twice
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4644 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/sched/task_exithook.c')
-rw-r--r--nuttx/sched/task_exithook.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/nuttx/sched/task_exithook.c b/nuttx/sched/task_exithook.c
index 44073165a..e160a1cb3 100644
--- a/nuttx/sched/task_exithook.c
+++ b/nuttx/sched/task_exithook.c
@@ -114,14 +114,32 @@ void task_exithook(FAR _TCB *tcb, int status)
#ifdef CONFIG_SCHED_ATEXIT
if (tcb->atexitfunc)
{
+ /* Call the atexit function */
+
(*tcb->atexitfunc)();
+
+ /* Nullify the atexit function. task_exithook may be called more then
+ * once in most task exit scenarios. Nullifying the atext function
+ * pointer will assure that the callback is performed only once.
+ */
+
+ tcb->atexitfunc = NULL;
}
#endif
#ifdef CONFIG_SCHED_ONEXIT
if (tcb->onexitfunc)
{
+ /* Call the on_exit function */
+
(*tcb->onexitfunc)(status, tcb->onexitarg);
+
+ /* Nullify the on_exit function. task_exithook may be called more then
+ * once in most task exit scenarios. Nullifying the on_exit function
+ * pointer will assure that the callback is performed only once.
+ */
+
+ tcb->onexitfunc = NULL;
}
#endif