sched/timer: timer_settime not fully satisfy IEEE 1003.1

If the specified time has already passed, the function
shall succeed and the expiration notification shall be made.
This commit is contained in:
larry 2022-07-16 08:46:05 +08:00 committed by Xiang Xiao
parent 19f269e54b
commit 2721e01fc2

View File

@ -306,18 +306,18 @@ int timer_settime(timer_t timerid, int flags,
goto errout; goto errout;
} }
/* If the time is in the past or now, then set up the next interval /* If the specified time has already passed, the function shall succeed
* instead (assuming a repetitive timer). * and the expiration notification shall be made.
*/ */
if (delay <= 0) if (delay < 0)
{ {
delay = timer->pt_delay; delay = 0;
} }
/* Then start the watchdog */ /* Then start the watchdog */
if (delay > 0) if (delay >= 0)
{ {
ret = wd_start(&timer->pt_wdog, delay, timer_timeout, (wdparm_t)timer); ret = wd_start(&timer->pt_wdog, delay, timer_timeout, (wdparm_t)timer);
if (ret < 0) if (ret < 0)