From 510d15195ce32ca9f5c32c56d09aaa607cb53451 Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Wed, 4 Mar 2015 11:46:32 +0100 Subject: [PATCH] plugins.c:generic_io_cb() -- Stop watcher before running callback Stop event watcher before running callback, the plugin may manipulate the descriptor and cause the kernel into a EPOLLHUP frenzy. Signed-off-by: Joachim Nilsson --- plugin.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/plugin.c b/plugin.c index 301a18a1..faa7e07a 100644 --- a/plugin.c +++ b/plugin.c @@ -167,12 +167,14 @@ static void generic_io_cb(uev_ctx_t *UNUSED(ctx), uev_t *w, void *arg, int event plugin_t *p = (plugin_t *)arg; if (is_io_plugin(p) && p->io.fd == w->fd) { + /* Stop watcher, callback may close descriptor on us ... */ + uev_io_stop(w); + _d("Calling I/O %s from runloop...", basename(p->name)); p->io.cb(p->io.arg, w->fd, events); /* Update fd, may be changed by plugin callback, e.g., if FIFO */ - if (p->io.fd != w->fd) - uev_io_set(w, p->io.fd, p->io.flags); + uev_io_set(w, p->io.fd, p->io.flags); } }