This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit a2328156487656157e92cfc12c8db3fe91325e81
Author: wangchengdong <[email protected]>
AuthorDate: Sun Nov 23 21:46:34 2025 +0800

    sched/signal: Fix remaining time calculation in nxsig_clockwait()
    
    Always compute the expected wake-up time by default, so the remaining
    time can be calculated correctly when the flag is not TIMER_ABSTIME.
    
    Signed-off-by: Chengdong Wang [email protected]
---
 sched/signal/sig_timedwait.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/sched/signal/sig_timedwait.c b/sched/signal/sig_timedwait.c
index 1837a7a4547..55c193ccbe6 100644
--- a/sched/signal/sig_timedwait.c
+++ b/sched/signal/sig_timedwait.c
@@ -238,19 +238,25 @@ int nxsig_clockwait(int clockid, int flags,
       if ((flags & TIMER_ABSTIME) == 0)
         {
           expect = clock_delay2abstick(clock_time2ticks(rqtp));
-          wd_start_abstick(&rtcb->waitdog, expect,
-                           nxsig_timeout, (uintptr_t)rtcb);
         }
       else if (clockid == CLOCK_REALTIME)
         {
-          wd_start_realtime(&rtcb->waitdog, rqtp,
-                            nxsig_timeout, (uintptr_t)rtcb);
+#ifdef CONFIG_CLOCK_TIMEKEEPING
+          clock_t delay;
+
+          clock_abstime2ticks(CLOCK_REALTIME, rqtp, &delay);
+          expect = clock_delay2abstick(delay);
+#else
+          clock_realtime2absticks(rqtp, &expect);
+#endif
         }
       else
         {
-          wd_start_abstime(&rtcb->waitdog, rqtp,
-                           nxsig_timeout, (uintptr_t)rtcb);
+          expect = clock_time2ticks(rqtp);
         }
+
+        wd_start_abstick(&rtcb->waitdog, expect,
+                          nxsig_timeout, (uintptr_t)rtcb);
     }
 
   /* Remove the tcb task from the ready-to-run list. */

Reply via email to