[Xenomai-git] Jan Kiszka : cobalt/posix/sem: Do not register named semaphores with process resources

2015-07-27 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: 1853acec4d2a790d47c8f1abebcec8eabb6fa9dc
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=1853acec4d2a790d47c8f1abebcec8eabb6fa9dc

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 |   19 +++
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/kernel/cobalt/posix/sem.c b/kernel/cobalt/posix/sem.c
index 08c4cc3..1c47f2a 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,10 @@ __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);
+   else
+   sem-resnode.scope = NULL;
sflags = flags  SEM_FIFO ? 0 : XNSYNCH_PRIO;
xnsynch_init(sem-synchbase, sflags, NULL);
 
@@ -178,7 +181,7 @@ static int sem_destroy(struct cobalt_sem_shadow *sm)
goto error;
}
 
-   if (sem_kqueue(sem) != sem-resnode.scope) {
+   if (sem-resnode.scope  sem_kqueue(sem) != sem-resnode.scope) {
ret = -EPERM;
goto error;
}
@@ -210,7 +213,7 @@ static inline int sem_trywait_inner(struct cobalt_sem *sem)
return -EINVAL;
 
if (IS_ENABLED(CONFIG_XENO_OPT_DEBUG_POSIX_SYNCHRO) 
-   sem-resnode.scope != sem_kqueue(sem))
+   sem-resnode.scope  sem-resnode.scope != sem_kqueue(sem))
return -EPERM;
 
if (atomic_sub_return(1, sem-state-value)  0)
@@ -385,7 +388,7 @@ static int sem_getvalue(xnhandle_t handle, int *value)
return -EINVAL;
}
 
-   if (sem-resnode.scope != sem_kqueue(sem)) {
+   if (sem-resnode.scope  sem-resnode.scope != sem_kqueue(sem)) {
xnlock_put_irqrestore(nklock, s);
return -EPERM;
}


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


[Xenomai-git] Jan Kiszka : cobalt/posix/sem: Do not register named semaphores with process resources

2015-07-17 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 1853acec4d2a790d47c8f1abebcec8eabb6fa9dc
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=1853acec4d2a790d47c8f1abebcec8eabb6fa9dc

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 |   19 +++
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/kernel/cobalt/posix/sem.c b/kernel/cobalt/posix/sem.c
index 08c4cc3..1c47f2a 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,10 @@ __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);
+   else
+   sem-resnode.scope = NULL;
sflags = flags  SEM_FIFO ? 0 : XNSYNCH_PRIO;
xnsynch_init(sem-synchbase, sflags, NULL);
 
@@ -178,7 +181,7 @@ static int sem_destroy(struct cobalt_sem_shadow *sm)
goto error;
}
 
-   if (sem_kqueue(sem) != sem-resnode.scope) {
+   if (sem-resnode.scope  sem_kqueue(sem) != sem-resnode.scope) {
ret = -EPERM;
goto error;
}
@@ -210,7 +213,7 @@ static inline int sem_trywait_inner(struct cobalt_sem *sem)
return -EINVAL;
 
if (IS_ENABLED(CONFIG_XENO_OPT_DEBUG_POSIX_SYNCHRO) 
-   sem-resnode.scope != sem_kqueue(sem))
+   sem-resnode.scope  sem-resnode.scope != sem_kqueue(sem))
return -EPERM;
 
if (atomic_sub_return(1, sem-state-value)  0)
@@ -385,7 +388,7 @@ static int sem_getvalue(xnhandle_t handle, int *value)
return -EINVAL;
}
 
-   if (sem-resnode.scope != sem_kqueue(sem)) {
+   if (sem-resnode.scope  sem-resnode.scope != sem_kqueue(sem)) {
xnlock_put_irqrestore(nklock, s);
return -EPERM;
}


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


[Xenomai-git] Jan Kiszka : cobalt/posix/sem: Do not register named semaphores with process resources

2015-07-17 Thread git repository hosting
Module: xenomai-jki
Branch: for-forge
Commit: f691fe721ed8f4ae92dbce99a49c92d808240884
URL:
http://git.xenomai.org/?p=xenomai-jki.git;a=commit;h=f691fe721ed8f4ae92dbce99a49c92d808240884

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 |   19 +++
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/kernel/cobalt/posix/sem.c b/kernel/cobalt/posix/sem.c
index 08c4cc3..1c47f2a 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,10 @@ __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);
+   else
+   sem-resnode.scope = NULL;
sflags = flags  SEM_FIFO ? 0 : XNSYNCH_PRIO;
xnsynch_init(sem-synchbase, sflags, NULL);
 
@@ -178,7 +181,7 @@ static int sem_destroy(struct cobalt_sem_shadow *sm)
goto error;
}
 
-   if (sem_kqueue(sem) != sem-resnode.scope) {
+   if (sem-resnode.scope  sem_kqueue(sem) != sem-resnode.scope) {
ret = -EPERM;
goto error;
}
@@ -210,7 +213,7 @@ static inline int sem_trywait_inner(struct cobalt_sem *sem)
return -EINVAL;
 
if (IS_ENABLED(CONFIG_XENO_OPT_DEBUG_POSIX_SYNCHRO) 
-   sem-resnode.scope != sem_kqueue(sem))
+   sem-resnode.scope  sem-resnode.scope != sem_kqueue(sem))
return -EPERM;
 
if (atomic_sub_return(1, sem-state-value)  0)
@@ -385,7 +388,7 @@ static int sem_getvalue(xnhandle_t handle, int *value)
return -EINVAL;
}
 
-   if (sem-resnode.scope != sem_kqueue(sem)) {
+   if (sem-resnode.scope  sem-resnode.scope != sem_kqueue(sem)) {
xnlock_put_irqrestore(nklock, s);
return -EPERM;
}


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


[Xenomai-git] Jan Kiszka : cobalt/posix/sem: Do not register named semaphores with process resources

2015-07-03 Thread git repository hosting
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