mirror of
https://github.com/troglobit/libuev.git
synced 2026-10-01 05:22:25 +07:00
Call watcher callback as last action for watcher, may delete itself
A watcher callback may be a timeout callback, or similar, that deletes itself and the watcher. So we should not dereference anything in the watcher after the callback. Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
@@ -365,9 +365,6 @@ int uev_run(uev_ctx_t *ctx, int flags)
|
||||
break;
|
||||
}
|
||||
|
||||
if (w->cb)
|
||||
w->cb(w, w->arg, events & UEV_EVENT_MASK);
|
||||
|
||||
if (UEV_CRON_TYPE == w->type) {
|
||||
if (!w->u.c.when)
|
||||
uev_timer_stop(w);
|
||||
@@ -376,6 +373,13 @@ int uev_run(uev_ctx_t *ctx, int flags)
|
||||
if (!w->u.t.timeout)
|
||||
uev_timer_stop(w);
|
||||
}
|
||||
|
||||
/*
|
||||
* NOTE: Must be last action for watcher, the
|
||||
* callback may delete itself.
|
||||
*/
|
||||
if (w->cb)
|
||||
w->cb(w, w->arg, events & UEV_EVENT_MASK);
|
||||
}
|
||||
|
||||
if (flags & UEV_ONCE)
|
||||
|
||||
Reference in New Issue
Block a user