Module: xenomai-forge
Branch: master
Commit: 4396906df348e16a22fc5ef829b9710acbd0a725
URL:    
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=4396906df348e16a22fc5ef829b9710acbd0a725

Author: Ronny Meeus <ronny.me...@gmail.com>
Date:   Tue Jul 23 16:42:30 2013 +0200

psos: handle EWOULDBLOCK error correctly in case of SM_NOWAIT flag

In case sm_p() is called with the SM_NOWAIT flag, error code
EWOULDBLOCK is returned if the semaphore is not available. This needs
to be translated in the correct psos error code (ERR_NOSEM).

Signed-off-by: Ronny Meeus <ronny.me...@gmail.com>

---

 lib/psos/sem.c             |    2 ++
 lib/psos/testsuite/sem-2.c |    3 +++
 2 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/lib/psos/sem.c b/lib/psos/sem.c
index 24865d6..4af5c8a 100644
--- a/lib/psos/sem.c
+++ b/lib/psos/sem.c
@@ -197,6 +197,8 @@ u_long sm_p(u_long smid, u_long flags, u_long timeout)
                        ret = ERR_SKILLD;
                else if (ret == -ETIMEDOUT)
                        ret = ERR_TIMEOUT;
+               else if (ret == -EWOULDBLOCK)
+                       ret = ERR_NOSEM;
                /*
                 * There is no explicit flush operation on pSOS
                 * semaphores, only an implicit one through deletion.
diff --git a/lib/psos/testsuite/sem-2.c b/lib/psos/testsuite/sem-2.c
index 4253a23..c516d42 100644
--- a/lib/psos/testsuite/sem-2.c
+++ b/lib/psos/testsuite/sem-2.c
@@ -28,6 +28,9 @@ static void task_A(u_long a0, u_long a1, u_long a2, u_long a3)
        ret = sm_p(sem_id, SM_NOWAIT, 0);
        traceobj_assert(&trobj, ret == SUCCESS);
 
+       ret = sm_p(sem_id, SM_NOWAIT, 0);
+       traceobj_assert(&trobj, ret == ERR_NOSEM);
+
        traceobj_mark(&trobj, 3);
 
        ret = sm_p(sem_id, SM_WAIT, 0);


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

Reply via email to