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

Author: Philippe Gerum <r...@xenomai.org>
Date:   Mon Nov  2 17:50:08 2009 +0100

nucleus: fix locking in shared heap deletion

---

 ksrc/nucleus/heap.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/ksrc/nucleus/heap.c b/ksrc/nucleus/heap.c
index ec14f73..37bb633 100644
--- a/ksrc/nucleus/heap.c
+++ b/ksrc/nucleus/heap.c
@@ -1249,10 +1249,13 @@ void xnheap_destroy_mapped(xnheap_t *heap,
         * some mapping still remains on the same heap, arming the
         * deferred release handler to clean it up via vmclose().
         */
+       spin_lock(&kheapq_lock);
+
        if (heap->archdep.numaps > 0) {
                /* The release handler is supposed to clean up the rest. */
-               XENO_ASSERT(NUCLEUS, release != NULL, /* nop */);
                heap->archdep.release = release;
+               spin_unlock(&kheapq_lock);
+               XENO_ASSERT(NUCLEUS, release != NULL, /* nop */);
                return;
        }
 
@@ -1264,8 +1267,8 @@ void xnheap_destroy_mapped(xnheap_t *heap,
         * been removed, because __validate_heap_addr() will deny
         * access to heaps pending a release.
         */
-       spin_lock(&kheapq_lock);
        removeq(&kheapq, &heap->link);
+
        spin_unlock(&kheapq_lock);
 
        __unreserve_and_free_heap(heap->archdep.heapbase, len,


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

Reply via email to