Module: xenomai-3 Branch: stable-3.0.x Commit: 73de42cc87f8831694f119359472283f8c7a21e6 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=73de42cc87f8831694f119359472283f8c7a21e6
Author: Philippe Gerum <r...@xenomai.org> Date: Wed Apr 11 16:21:22 2018 +0200 copperplate/threadobj: honor -EWOULDBLOCK upon invalid wait_period() Caller of threadobj_wait_period() should receive -EWOULDBLOCK if threadobj_set_periodic() was not issued earlier. --- lib/copperplate/threadobj.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/copperplate/threadobj.c b/lib/copperplate/threadobj.c index cde1548..d9e9267 100644 --- a/lib/copperplate/threadobj.c +++ b/lib/copperplate/threadobj.c @@ -1625,25 +1625,28 @@ int threadobj_set_periodic(struct threadobj *thobj, { /* thobj->lock held */ struct itimerspec its; struct sigevent sev; + timer_t timer; int ret; __threadobj_check_locked(thobj); - if (thobj->periodic_timer == NULL) { + timer = thobj->periodic_timer; + if (timer == NULL) { memset(&sev, 0, sizeof(sev)); sev.sigev_signo = SIGPERIOD; sev.sigev_notify = SIGEV_SIGNAL|SIGEV_THREAD_ID; sev.sigev_notify_thread_id = threadobj_get_pid(thobj); - ret = __RT(timer_create(CLOCK_COPPERPLATE, &sev, - &thobj->periodic_timer)); + ret = __RT(timer_create(CLOCK_COPPERPLATE, &sev, &timer)); if (ret) return __bt(-errno); - } + thobj->periodic_timer = timer; + } else if (!timespec_scalar(idate) && !timespec_scalar(period)) + thobj->periodic_timer = NULL; its.it_value = *idate; its.it_interval = *period; - ret = __RT(timer_settime(thobj->periodic_timer, TIMER_ABSTIME, &its, NULL)); + ret = __RT(timer_settime(timer, TIMER_ABSTIME, &its, NULL)); if (ret) return __bt(-errno); @@ -1656,6 +1659,9 @@ int threadobj_wait_period(unsigned long *overruns_r) siginfo_t si; int sig; + if (current->periodic_timer == NULL) + return -EWOULDBLOCK; + for (;;) { current->run_state = __THREAD_S_DELAYED; sig = __RT(sigwaitinfo(&sigperiod_set, &si)); _______________________________________________ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git