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

Author: Jan Kiszka <jan.kis...@siemens.com>
Date:   Tue Jun 30 20:26:08 2015 +0200

cobalt/posix/sem: Do not register named semaphores with process resources

Named semaphores are reclaimed via their own mechanism. Having them
registered also as process-local resource will cause their destruction
on process termination if no other process holds a reference. This is
not conforming to the specification, and the smokey leaks tests fails
due to this right now.

Signed-off-by: Jan Kiszka <jan.kis...@siemens.com>

---

 kernel/cobalt/posix/sem.c |   11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/kernel/cobalt/posix/sem.c b/kernel/cobalt/posix/sem.c
index e63967f..7ade350 100644
--- a/kernel/cobalt/posix/sem.c
+++ b/kernel/cobalt/posix/sem.c
@@ -50,7 +50,8 @@ int __cobalt_sem_destroy(xnhandle_t handle)
 
        cobalt_mark_deleted(sem);
        xnregistry_remove(sem->resnode.handle);
-       cobalt_del_resource(&sem->resnode);
+       if (!sem->pathname)
+               cobalt_del_resource(&sem->resnode);
        if (xnsynch_destroy(&sem->synchbase) == XNSYNCH_RESCHED) {
                xnsched_run();
                ret = 1;
@@ -106,9 +107,8 @@ __cobalt_sem_init(const char *name, struct 
cobalt_sem_shadow *sm,
        xnlock_get_irqsave(&nklock, s);
 
        semq = &cobalt_current_resources(pshared)->semq;
-       if (!list_empty(semq) &&
-           (sm->magic == COBALT_SEM_MAGIC ||
-            sm->magic == COBALT_NAMED_SEM_MAGIC)) {
+       if ((sm->magic == COBALT_SEM_MAGIC && !list_empty(semq)) ||
+           sm->magic == COBALT_NAMED_SEM_MAGIC) {
                osem = xnregistry_lookup(sm->handle, NULL);
                if (cobalt_obj_active(osem, COBALT_SEM_MAGIC, typeof(*osem))) {
                        ret = -EBUSY;
@@ -126,7 +126,8 @@ __cobalt_sem_init(const char *name, struct 
cobalt_sem_shadow *sm,
                goto err_lock_put;
 
        sem->magic = COBALT_SEM_MAGIC;
-       cobalt_add_resource(&sem->resnode, sem, pshared);
+       if (!name)
+               cobalt_add_resource(&sem->resnode, sem, pshared);
        sflags = flags & SEM_FIFO ? 0 : XNSYNCH_PRIO;
        xnsynch_init(&sem->synchbase, sflags, NULL);
 


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

Reply via email to