Module: xenomai-jki Branch: for-upstream Commit: 5d2fa6c7578683e036d88bc6dbb6a7f458dfe705 URL: http://git.xenomai.org/?p=xenomai-jki.git;a=commit;h=5d2fa6c7578683e036d88bc6dbb6a7f458dfe705
Author: Jan Kiszka <[email protected]> Date: Wed Apr 28 15:08:11 2010 +0200 native: Improve fault tolerance /wrt multiple task deletions As we may pass the pthread handle of an RT_TASK directly to glibc, we may trigger a SIGSEGV if the underlying thread was already terminated. Try to catch this application mistakes by clearing the handle at least in that task descriptor which successfully ran rt_task_delete or rt_task_join. Signed-off-by: Jan Kiszka <[email protected]> --- src/skins/native/task.c | 11 ++++++++++- 1 files changed, 10 insertions(+), 1 deletions(-) diff --git a/src/skins/native/task.c b/src/skins/native/task.c index d975508..e1f3833 100644 --- a/src/skins/native/task.c +++ b/src/skins/native/task.c @@ -269,6 +269,8 @@ int rt_task_delete(RT_TASK *task) err = pthread_cancel((pthread_t)task->opaque2); if (err) return -err; + + task->opaque2 = 0; } err = XENOMAI_SKINCALL1(__native_muxid, __native_task_delete, task); @@ -367,10 +369,17 @@ int rt_task_slice(RT_TASK *task, RTIME quantum) int rt_task_join(RT_TASK *task) { + int err; + if (!task->opaque2) return -ESRCH; - return -pthread_join((pthread_t)task->opaque2, NULL); + err = -pthread_join((pthread_t)task->opaque2, NULL); + + if (!err) + task->opaque2 = 0; + + return err; } ssize_t rt_task_send(RT_TASK *task, _______________________________________________ Xenomai-git mailing list [email protected] https://mail.gna.org/listinfo/xenomai-git
