Module: xenomai-head
Branch: master
Commit: 3042812328dba9c5026a51b12d049e61e4999373
URL:    
http://git.xenomai.org/?p=xenomai-head.git;a=commit;h=3042812328dba9c5026a51b12d049e61e4999373

Author: Gilles Chanteperdrix <gilles.chanteperd...@xenomai.org>
Date:   Sun Aug 22 16:09:58 2010 +0200

Set user-space current thread handle to XN_NO_HANDLE after fork

---

 include/asm-generic/bits/current.h |    5 +++++
 src/skins/common/current.c         |   12 ++++++++++--
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/include/asm-generic/bits/current.h 
b/include/asm-generic/bits/current.h
index 0f299ea..79123e8 100644
--- a/include/asm-generic/bits/current.h
+++ b/include/asm-generic/bits/current.h
@@ -32,6 +32,10 @@ static inline unsigned long xeno_get_current_mode(void)
 #else /* ! HAVE___THREAD */
 extern pthread_key_t xeno_current_key;
 
+xnhandle_t xeno_slow_get_current(void);
+
+unsigned long xeno_slow_get_current_mode(void);
+
 static inline xnhandle_t xeno_get_current(void)
 {
        void *val = pthread_getspecific(xeno_current_key);
@@ -59,6 +63,7 @@ static inline unsigned long xeno_get_current_mode(void)
 void xeno_set_current(void);
 
 unsigned long *xeno_init_current_mode(void);
+
 void xeno_init_current_keys(void);
 
 #endif /* _XENO_ASM_GENERIC_CURRENT_H */
diff --git a/src/skins/common/current.c b/src/skins/common/current.c
index 4e75690..50d8a65 100644
--- a/src/skins/common/current.c
+++ b/src/skins/common/current.c
@@ -3,10 +3,11 @@
 #include <string.h>
 #include <pthread.h>
 
-#include <asm/xenomai/syscall.h>
 #include <nucleus/types.h>
 #include <nucleus/thread.h>
 #include <nucleus/vdso.h>
+#include <asm/xenomai/syscall.h>
+#include <asm-generic/bits/current.h>
 
 pthread_key_t xeno_current_mode_key;
 
@@ -85,13 +86,20 @@ static void cleanup_current_mode(void *key)
        }
 }
 
+static void xeno_current_fork_handler(void)
+{
+       if (xeno_get_current() != XN_NO_HANDLE)
+               __xeno_set_current(XN_NO_HANDLE);
+}
+
 static void init_current_keys(void)
 {
        int err = create_current_key();
-
        if (err)
                goto error_exit;
 
+       pthread_atfork(NULL, NULL, &xeno_current_fork_handler);
+
        err = pthread_key_create(&xeno_current_mode_key, cleanup_current_mode);
        if (err) {
          error_exit:


_______________________________________________
Xenomai-git mailing list
Xenomai-git@gna.org
https://mail.gna.org/listinfo/xenomai-git

Reply via email to