Module: xenomai-forge Branch: master Commit: bad876f470b37db9292a37ec346e8f69eafafe46 URL: http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=bad876f470b37db9292a37ec346e8f69eafafe46
Author: Philippe Gerum <r...@xenomai.org> Date: Sat Nov 12 23:00:05 2011 +0100 alchemy: fix timeout handling on binding operation --- lib/alchemy/internal.c | 16 +++++++++++++++- lib/alchemy/internal.h | 3 +++ lib/alchemy/testsuite/task-3.c | 9 +++++++++ 3 files changed, 27 insertions(+), 1 deletions(-) diff --git a/lib/alchemy/internal.c b/lib/alchemy/internal.c index 33eb87c..09b7b76 100644 --- a/lib/alchemy/internal.c +++ b/lib/alchemy/internal.c @@ -68,6 +68,20 @@ struct timespec *alchemy_get_timespec(RTIME timeout, struct timespec *tmp) return tmp; } +struct timespec *alchemy_get_timeout(RTIME timeout, struct timespec *tmp) +{ + if (timeout == TM_INFINITE) + return NULL; + + if (timeout == TM_NONBLOCK) { + tmp->tv_sec = 0; + tmp->tv_nsec = 0; + } else + clockobj_ticks_to_timeout(&alchemy_clock, timeout, tmp); + + return tmp; +} + int alchemy_bind_object(const char *name, struct syncluster *sc, RTIME timeout, int offset, @@ -80,7 +94,7 @@ int alchemy_bind_object(const char *name, struct syncluster *sc, int ret; COPPERPLATE_PROTECT(svc); - timespec = alchemy_get_timespec(timeout, &ts); + timespec = alchemy_get_timeout(timeout, &ts); ret = syncluster_findobj(sc, name, timespec, &cobj); COPPERPLATE_UNPROTECT(svc); if (ret) diff --git a/lib/alchemy/internal.h b/lib/alchemy/internal.h index 86b0f21..6389985 100644 --- a/lib/alchemy/internal.h +++ b/lib/alchemy/internal.h @@ -37,6 +37,9 @@ RTIME alchemy_rel2abs_timeout(RTIME timeout); struct timespec *alchemy_get_timespec(RTIME timeout, struct timespec *tmp); +struct timespec *alchemy_get_timeout(RTIME timeout, + struct timespec *tmp); + int alchemy_bind_object(const char *name, struct syncluster *sc, RTIME timeout, int offset, diff --git a/lib/alchemy/testsuite/task-3.c b/lib/alchemy/testsuite/task-3.c index 9432c92..aa3af9a 100644 --- a/lib/alchemy/testsuite/task-3.c +++ b/lib/alchemy/testsuite/task-3.c @@ -41,5 +41,14 @@ int main(int argc, char *argv[]) ret = rt_task_bind(&t, "taskB", TM_NONBLOCK); traceobj_assert(&trobj, ret == -EWOULDBLOCK); + ret = rt_task_bind(&t, "taskB", 1000000000ULL); + traceobj_assert(&trobj, ret == -EPERM); + + ret = rt_task_shadow(NULL, "main", 1, 0); + traceobj_assert(&trobj, ret == 0); + + ret = rt_task_bind(&t, "taskB", 1000000000ULL); + traceobj_assert(&trobj, ret == -ETIMEDOUT); + exit(0); } _______________________________________________ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git