Commit Graph
12 Commits
Author SHA1 Message Date
omrzk 09d9b6ba04 Keep timer deadlines between calls to uev_run()
Timers never expire when the event loop is run one iteration at a time
and something else keeps it busy, e.g., when polled from another event
loop:

    uev_run(ctx, UEV_ONCE | UEV_NONBLOCK);

Every call to uev_run() starts all timers over from their full timeout.

Start dormant timers on the first call only.  A caller that wants a
timer restarted for each call must now use uev_timer_set().

Closes #36
2026-11-16 15:08:41 +01:00
NefelibateLG 05bc6a0830 Do not leave stdin as descriptor of a failed context
uev_init() leaves the context descriptor at 0 when epoll_create1()
fails.  A following uev_exit() then closes stdin.

Set it to -1 before creating the epoll descriptor.
2026-11-16 14:54:49 +01:00
NefelibateLG 4792b988a1 Fix eventfd leak in uev_event_init()
uev_event_init() leaks its eventfd, and leaves it in the watcher, when
the watcher cannot be added to the event loop.

Close it and reset the descriptor in the watcher.
2026-11-16 14:54:49 +01:00
NefelibateLG ae28276f3f Fix restart of a stopped cron watcher
uev_cron_start() on a stopped cron watcher brings it back as a regular
timer, with a timeout made up of parts of the cron schedule.  It calls
uev_timer_start(), which reads the timer fields of the watcher and
creates a monotonic timer.

Restart with uev_cron_set() and the cron schedule instead.
2026-11-16 14:54:48 +01:00
omrzk e699cb7f5f Honor UEV_ONCE when stdin is redirected from a file
With stdin redirected from a regular file, uev_run() with UEV_ONCE does
not return until end of file:

    app < file.txt

The workaround for regular files, which epoll cannot watch, restarts
the loop before the UEV_ONCE check.

Check the flag there too.

Closes #37
2026-11-16 14:54:47 +01:00
omrzk fbe2c15377 Honor new descriptor and events in uev_io_set()
uev_io_set() on an active oneshot watcher keeps watching the old
descriptor, for the old events:

    uev_io_set(w, newfd, UEV_READ | UEV_ONESHOT);

It only rearms the watcher, with what is already stored in it.

Rearm only when neither has changed, otherwise stop the watcher and set
it up again.

Closes #35
2026-11-16 14:54:46 +01:00
Joachim Wiberg 0f59096154 Update copyright years
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-01-04 17:16:49 +01:00
Joachim Wiberg 270e270591 test: fix signed vs unsigned comparison
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-12-17 15:01:25 +01:00
Joachim Wiberg 02832543e3 test: use AM_LDFLAGS for linker args to test programs
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-10-03 08:13:21 +02:00
Joachim Wiberg c8d1de10a3 test: prefix CFLAGS/CPPFLAGS with AM_ to avoid clash with Fedora
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-10-03 07:40:06 +02:00
Joachim Wiberg 0e0291f85e Fix #25: apps must be built with 64-bit time, just like the lib
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-10-02 17:21:17 +02:00
Joachim Wiberg caa62910db Relocate tests/ -> test/
For my own sanity, test/ is used in every other project of mine.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-08-01 22:40:35 +02:00