Module: xenomai-forge
Branch: next
Commit: 086b88ce71756d519b8cf0f2eba681cb3528a02f
URL:    
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=086b88ce71756d519b8cf0f2eba681cb3528a02f

Author: Philippe Gerum <r...@xenomai.org>
Date:   Fri Aug 22 11:10:26 2014 +0200

cobalt/posix/process: keep process backlink cleared after fork->exec sequence

---

 kernel/cobalt/posix/process.c |   19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/kernel/cobalt/posix/process.c b/kernel/cobalt/posix/process.c
index a42757c..256a3d3 100644
--- a/kernel/cobalt/posix/process.c
+++ b/kernel/cobalt/posix/process.c
@@ -200,9 +200,9 @@ static void remove_process(struct cobalt_process *process)
                }
        }
 
-       mutex_unlock(&personality_lock);
-
        cobalt_set_process(NULL);
+
+       mutex_unlock(&personality_lock);
 }
 
 static int enter_personality(struct cobalt_process *process,
@@ -1257,8 +1257,12 @@ static int handle_cleanup_event(struct mm_struct *mm)
        struct xnsys_ppd *sys_ppd;
        struct xnthread *thread;
 
-       /* We are NOT called for exiting kernel shadows. */
-
+       /*
+        * We are NOT called for exiting kernel shadows.
+        * cobalt_current_process() is cleared if we get there after
+        * handle_task_exit(), so we need to restore this context
+        * pointer temporarily.
+        */
        process = cobalt_search_process(mm);
        old = cobalt_set_process(process);
        sys_ppd = cobalt_ppd_get(0);
@@ -1281,7 +1285,12 @@ static int handle_cleanup_event(struct mm_struct *mm)
                        remove_process(process);
        }
 
-       cobalt_set_process(old);
+       /*
+        * CAUTION: Do not override a state change caused by
+        * remove_process().
+        */
+       if (cobalt_current_process() == process)
+               cobalt_set_process(old);
 
        return KEVENT_PROPAGATE;
 }


_______________________________________________
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://www.xenomai.org/mailman/listinfo/xenomai-git

Reply via email to