From: Davin McCall Date: Sun, 19 Jun 2016 19:11:17 +0000 (+0100) Subject: Fix kqueue backend bug; wasn't disabling read/write channels of a X-Git-Tag: v0.04~29^2 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=118be9e48765bf20207d7eecfbd17541a4424be9;p=oweals%2Fdinit.git Fix kqueue backend bug; wasn't disabling read/write channels of a Bidi watcher appropriately when watcher added --- 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());