Module: xenomai-3
Branch: next
Commit: 669004c5eda5ffc0d32b121e958711d5d4ead38d
URL:    
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=669004c5eda5ffc0d32b121e958711d5d4ead38d

Author: Philippe Gerum <r...@xenomai.org>
Date:   Fri Jan 23 16:16:32 2015 +0100

copperplate/threadobj: fix race on early thread exit

---

 lib/copperplate/threadobj.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/copperplate/threadobj.c b/lib/copperplate/threadobj.c
index 32fbf01..16f23f8 100644
--- a/lib/copperplate/threadobj.c
+++ b/lib/copperplate/threadobj.c
@@ -1080,7 +1080,6 @@ int threadobj_start(struct threadobj *thobj)      /* 
thobj->lock held. */
 
        thobj->status |= __THREAD_S_SAFE;
        wait_on_barrier(thobj, __THREAD_S_ACTIVE);
-       thobj->status &= ~__THREAD_S_SAFE;
 
        /*
         * If the started thread has exited before we woke up from the
@@ -1095,7 +1094,8 @@ int threadobj_start(struct threadobj *thobj)      /* 
thobj->lock held. */
                destroy_thread(thobj);
                threadobj_free(thobj);
                ret = -EIDRM;
-       }
+       } else
+               thobj->status &= ~__THREAD_S_SAFE;
 
        pthread_setcancelstate(oldstate, NULL);
 


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

Reply via email to