mirror of
https://github.com/troglobit/libuev.git
synced 2026-10-28 11:50:42 +00: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:
1 parent
a528405258
commit
dd651ae791
1 file changed
+7
-3
@@ -365,9 +365,6 @@ int uev_run(uev_ctx_t *ctx, int flags)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (w->cb)
|
|
||||||
w->cb(w, w->arg, events & UEV_EVENT_MASK);
|
|
||||||
|
|
||||||
if (UEV_CRON_TYPE == w->type) {
|
if (UEV_CRON_TYPE == w->type) {
|
||||||
if (!w->u.c.when)
|
if (!w->u.c.when)
|
||||||
uev_timer_stop(w);
|
uev_timer_stop(w);
|
||||||
@@ -376,6 +373,13 @@ int uev_run(uev_ctx_t *ctx, int flags)
|
|||||||
if (!w->u.t.timeout)
|
if (!w->u.t.timeout)
|
||||||
uev_timer_stop(w);
|
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)
|
if (flags & UEV_ONCE)
|
||||||
|
|||||||
Reference in new issue
Block a user