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
This commit is contained in:
omrzk authored and Joachim Wiberg committed 2026-11-16 14:54:46 +01:00
1 parent c964bbe8fb
commit fbe2c15377
4 files changed
+64 -1

No files matched your search

+2 -1
View File
@@ -64,7 +64,8 @@ int uev_io_init(uev_ctx_t *ctx, uev_t *w, uev_cb_t *cb, void *arg, int fd, int e
*/
int uev_io_set(uev_t *w, int fd, int events)
{
if ((events & UEV_ONESHOT) && _uev_watcher_active(w))
if ((events & UEV_ONESHOT) && _uev_watcher_active(w) &&
fd == w->fd && events == w->events)
return _uev_watcher_rearm(w);
/* Ignore any errors, only to clean up anything lingering ... */