From c919b5f81ad6cad55935fa7a22bfda9539dd584f Mon Sep 17 00:00:00 2001 From: eunhhu Date: Tue, 29 Sep 2026 18:12:23 +0100 Subject: Wait for timers on the monotonic clock; events still see the wall clock The terminal, the pixel surfaces and the web page reckoned when a timer was due on the wall clock: set back, a timer waited until the clock came again to the tick it had waited for (Pure's review 004). vega_clock is the monotonic clock; timers are due on it, and a tick sets the time its event sees from the wall clock (vega_now), as before. check.py's clock_set_back runs a timer of 20 ms in the terminal with the wall clock set back an hour 0.2 s in (Pure's build/clock-back.so, an LD_PRELOAD of clock_gettime): 40 ticks in 0.8 s, where Vega before this stops at 9. make check passes it --clock-back. --- surfaces/web.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'surfaces/web.c') diff --git a/surfaces/web.c b/surfaces/web.c index 7103c8f..a4759c4 100644 --- a/surfaces/web.c +++ b/surfaces/web.c @@ -418,11 +418,11 @@ int vega_web(PureApp *app, const VegaScreen *screen, const char *listen_on, unsi static Client clients[CLIENTS]; for (unsigned i = 0; i < CLIENTS; ++i) clients[i].fd = -1; VegaTimers timers; - vega_timers_start(&timers, app->module, vega_now()); + vega_timers_start(&timers, app->module, vega_clock()); while (!stopping) { /* Tick what is due; every page hears of it this round, without waiting. */ bool ticked = false; - long due = vega_timers_run(&timers, app, vega_now(), &ticked); + long due = vega_timers_run(&timers, app, vega_clock(), &ticked); struct pollfd fds[CLIENTS + 1]; unsigned slot[CLIENTS + 1], count = 1; fds[0] = (struct pollfd){listener, POLLIN, 0}; @@ -441,7 +441,7 @@ int vega_web(PureApp *app, const VegaScreen *screen, const char *listen_on, unsi if (ready == 0 && screen->ticks) changed = pure_app_frame(app) == PURE_OK; if (reload && reload()) { /* a new module: every page draws it */ changed = true; - vega_timers_start(&timers, app->module, app->now); + vega_timers_start(&timers, app->module, vega_clock()); } if (fds[0].revents & POLLIN) for (int fd; (fd = accept4(listener, NULL, NULL, SOCK_NONBLOCK | SOCK_CLOEXEC)) >= 0;) { -- cgit v1.2.3