-
Notifications
You must be signed in to change notification settings - Fork 433
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Timer corruption when using mgos_settimeofday after setting a MGOS_TIMER_RUN_NOW timer #567
Comments
Forgot to add, the platform tested is ESP32. And I've added SNTP and WiFi in case you want to test it out with a real clock value, for which the same happens. |
Upon further examination. The issue happens when the time set by In this case, the timer corruption happens when the set time is less than the current time while we have a pending timer. |
ugh... another case where using wall time for timers hurts. we should really switch to uptime! ok, point taken. |
@rojer Would this line change be enough as a stopgap measure to avoid this issue while the migration to uptime is done? https://gist.github.com/DrBomb/f279be42181d1e1635a7c8b6a8e874cb#file-mgos_timers-c-L190 SNTP is emitting negative-time deltas and I believe it is still screwing up the timers on our deployments |
pushed the uptime change. try now, it should fix the issue. |
Issue
If you make a call to
mgos_settimeofday
after setting a timer with theMGOS_TIMER_RUN_NOW
flag, the timer gets a negativenext_invocation
value, breaking all the timers in the system. Affecting even cronjobs as well.Sample app with reproduction steps, some background and a patch to visualize the issue is available here:
https://github.com/DrBomb/TimerCorruption
The text was updated successfully, but these errors were encountered: