aboutsummaryrefslogtreecommitdiff
path: root/src/timer.c
Commit message (Collapse)AuthorAge
* src: remove unused include of <assert.h> in timer.c (#4774)Juan José2025-05-02
| | | Signed-off-by: Juan José Arboleda <soyjuanarbol@gmail.com>
* unix,win: reset the timer queue on stop (#4304)Santiago Gimeno2024-02-07
| | | | | | As there were instances where this didn't happen and could cause memory corruption issues. Refs: https://github.com/libuv/libuv/issues/4248
* unix,win: fix busy loop with zero timeout timers (#4250)Matheus Izvekov2023-12-22
| | | | | | | | | | | | | | Calling `uv_timer_start(h, cb, 0, 0)` from a timer callback resulted in the timer running immediately because it was inserted at the front of the timer heap. If the callback did that every time, libuv would effectively busy-loop in `uv__run_timers()` and never make forward progress. Work around that by collecting all expired timers into a queue and only running their callback afterwards. Fixes: https://github.com/libuv/libuv/issues/4245 Co-authored-by: Ben Noordhuis <info@bnoordhuis.nl>
* unix,win: initialize timer `timeout` fieldBen Noordhuis2020-11-18
| | | | | | | | | | | | | | | | | | | | | | | | | With the addition of `uv_timer_get_due_in()` it's observable with tools like valgrind that the `timer->timeout` field isn't initialized until the timer is started. Fixes the following valgrind warning when running the `timer_init` test: ==325215== Conditional jump or move depends on uninitialised value(s) ==325215== at 0x1B0131: uv_timer_get_due_in (timer.c:134) ==325215== by 0x19AF09: run_test_timer_init (test-timer.c:164) ==325215== by 0x119FF1: run_test_part (runner.c:376) ==325215== by 0x11875D: main (run-tests.c:68) ==325215== ==325215== Conditional jump or move depends on uninitialised value(s) ==325215== at 0x19AF1F: run_test_timer_init (test-timer.c:164) ==325215== by 0x119FF1: run_test_part (runner.c:376) ==325215== by 0x11875D: main (run-tests.c:68) Fixes: https://github.com/libuv/libuv/issues/3020 PR-URL: https://github.com/libuv/libuv/pull/3038 Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Jameson Nash <vtjnash@gmail.com>
* unix,win: add uv_timer_get_due_in()Ulrik Strid2020-09-21
| | | | | | | | | | Co-authored-by: Jeremiah Senkpiel <fishrock123@rocketmail.com> Refs: https://github.com/nodejs/node-report/pull/73 Refs: https://github.com/libuv/libuv/pull/1255 Fixes: https://github.com/libuv/libuv/issues/2950 PR-URL: https://github.com/libuv/libuv/pull/2951 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
* timer: remove redundant check in heap compareYash Ladha2020-04-16
| | | | | | | | | | | | `timer_less_than()` function is basically a comparator function that returns true or false. In the end of the function we were checking for the comparison of id, but the later if is redundant as we are anyways in the end are returning `0`. That extra check can thus be safely removed. PR-URL: https://github.com/libuv/libuv/pull/2785 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
* src: fix wrong method name in commentTK-one2020-02-28
| | | | | | PR-URL: https://github.com/libuv/libuv/pull/2689 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
* timer: fix uv_timer_start on closing timerseny2019-08-23
| | | | | | | | | | | Return `UV_EINVAL` in this case. Fixes: https://github.com/libuv/libuv/issues/2416 PR-URL: https://github.com/libuv/libuv/pull/2424 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
* warnings: fix code that emits compiler warningsJameson Nash2018-11-29
| | | | | | PR-URL: https://github.com/libuv/libuv/pull/2066 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Refael Ackermann <refack@gmail.com>
* unix,win: merge timers implementationBen Noordhuis2018-06-25
Merge src/unix/timer.c and src/win/timer.c into src/timer.c. This changes the Windows implementation from a binary tree to a binary heap for generally better performance. PR-URL: https://github.com/libuv/libuv/pull/1882 Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>