From 118be9e48765bf20207d7eecfbd17541a4424be9 Mon Sep 17 00:00:00 2001 From: Davin McCall Date: Sun, 19 Jun 2016 20:11:17 +0100 Subject: [PATCH] Fix kqueue backend bug; wasn't disabling read/write channels of a Bidi watcher appropriately when watcher added --- src/dasynq/dasynq-kqueue.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/dasynq/dasynq-kqueue.h b/src/dasynq/dasynq-kqueue.h index 48fa983..dd3765a 100644 --- a/src/dasynq/dasynq-kqueue.h +++ b/src/dasynq/dasynq-kqueue.h @@ -215,8 +215,10 @@ template class KqueueLoop : public Base void addBidiFdWatch(int fd, void *userdata, int flags) { struct kevent kev[2]; - EV_SET(&kev[0], fd, EVFILT_READ, EV_ADD, 0, 0, userdata); - EV_SET(&kev[1], fd, EVFILT_WRITE, EV_ADD, 0, 0, userdata); + short rflags = EV_ADD | ((flags & IN_EVENTS) ? 0 : EV_DISABLE); + short wflags = EV_ADD | ((flags & OUT_EVENTS) ? 0 : EV_DISABLE); + EV_SET(&kev[0], fd, EVFILT_READ, rflags, 0, 0, userdata); + EV_SET(&kev[1], fd, EVFILT_WRITE, wflags, 0, 0, userdata); if (kevent(kqfd, kev, 2, nullptr, 0, nullptr) == -1) { throw new std::system_error(errno, std::system_category()); -- 2.25.1