Module: xenomai-forge Branch: master Commit: 458b24f19fbcde5d5d79afcab8f26b00d6abf0a4 URL: http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=458b24f19fbcde5d5d79afcab8f26b00d6abf0a4
Author: Philippe Gerum <[email protected]> Date: Sat Nov 12 23:00:05 2011 +0100 alchemy: fix timeout handling on binding operation --- lib/alchemy/internal.c | 23 +++++++++++++++++++---- lib/alchemy/internal.h | 3 +++ lib/alchemy/testsuite/task-3.c | 9 +++++++++ 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/lib/alchemy/internal.c b/lib/alchemy/internal.c index 33eb87c..fd2479c 100644 --- a/lib/alchemy/internal.c +++ b/lib/alchemy/internal.c @@ -60,10 +60,25 @@ struct timespec *alchemy_get_timespec(RTIME timeout, struct timespec *tmp) if (timeout == TM_INFINITE) return NULL; - if (timeout == TM_NONBLOCK) - timeout = 0; + if (timeout == TM_NONBLOCK) { + tmp->tv_sec = 0; + tmp->tv_nsec = 0; + } else + clockobj_ticks_to_timespec(&alchemy_clock, timeout, tmp); - clockobj_ticks_to_timespec(&alchemy_clock, timeout, 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; } @@ -80,7 +95,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 [email protected] https://mail.gna.org/listinfo/xenomai-git
