summaryrefslogtreecommitdiff
path: root/src/common/mainloop.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/mainloop.c')
-rw-r--r--src/common/mainloop.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/common/mainloop.c b/src/common/mainloop.c
index cff4385..950c581 100644
--- a/src/common/mainloop.c
+++ b/src/common/mainloop.c
@@ -2140,12 +2140,15 @@ static void dispatch_subloops(mrp_mainloop_t *ml)
}
-static void dispatch_slaves(mrp_io_watch_t *w, struct epoll_event *e)
+static void dispatch_slaves(mrp_mainloop_t *ml, mrp_io_watch_t *w, struct epoll_event *e)
{
mrp_io_watch_t *s;
mrp_list_hook_t *p, *n;
mrp_io_event_t events;
+ if (ml->quit)
+ return;
+
events = e->events & ~(MRP_IO_EVENT_INOUT & w->events);
mrp_list_foreach(&w->slave, p, n) {
@@ -2156,7 +2159,9 @@ static void dispatch_slaves(mrp_io_watch_t *w, struct epoll_event *e)
if (!is_deleted(s)) {
mrp_debug("dispatching slave I/O watch %p (fd %d)", s, s->fd);
+ pthread_mutex_unlock(&ml->lock);
s->cb(s, s->fd, events, s->user_data);
+ pthread_mutex_lock(&ml->lock);
}
else
mrp_debug("skipping slave I/O watch %p (fd %d)", s, s->fd);
@@ -2191,7 +2196,7 @@ static void dispatch_poll_events(mrp_mainloop_t *ml)
mrp_debug("skipping deleted I/O watch %p (fd %d)", w, fd);
if (!mrp_list_empty(&w->slave))
- dispatch_slaves(w, e);
+ dispatch_slaves(ml, w, e);
if (e->events & EPOLLRDHUP) {
tblw = fdtbl_lookup(ml->fdtbl, w->fd);