Module: xenomai-gch
Branch: for-forge
Commit: e55f70bc55ea8f408eabaa9aee635a4b0547294d
URL:    
http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=e55f70bc55ea8f408eabaa9aee635a4b0547294d

Author: Gilles Chanteperdrix <gilles.chanteperd...@xenomai.org>
Date:   Sun Oct 11 19:13:53 2015 +0200

cobalt/mutex: invalidate autoinit mutex upon fork

In order to avoid an EBUSY error because the same mutex is reinitialized
by the child process.

---

 lib/cobalt/mutex.c |    3 +++
 1 file changed, 3 insertions(+)

diff --git a/lib/cobalt/mutex.c b/lib/cobalt/mutex.c
index f613478..daf0e3a 100644
--- a/lib/cobalt/mutex.c
+++ b/lib/cobalt/mutex.c
@@ -60,6 +60,8 @@ static pthread_mutex_t cobalt_autoinit_mutex;
 
 void cobalt_mutex_init(void)
 {
+       struct cobalt_mutex_shadow *_mutex =
+               &((union cobalt_mutex_union 
*)&cobalt_autoinit_mutex)->shadow_mutex;
        pthread_mutexattr_t rt_init_mattr;
        int err __attribute__((unused));
 
@@ -67,6 +69,7 @@ void cobalt_mutex_init(void)
 
        pthread_mutexattr_init(&rt_init_mattr);
        pthread_mutexattr_setprotocol(&rt_init_mattr, PTHREAD_PRIO_INHERIT);
+       _mutex->magic = ~COBALT_MUTEX_MAGIC;
        err = __COBALT(pthread_mutex_init(&cobalt_autoinit_mutex,
                                                &rt_init_mattr));
        assert(err == 0);


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

Reply via email to