From fae73d14064dc9538ffb4b1a5aa3347878cbaba9 Mon Sep 17 00:00:00 2001 From: guonaihong Date: Mon, 18 Sep 2023 14:52:44 +0800 Subject: [PATCH] =?UTF-8?q?fix=E4=B8=8D=E5=81=9C=E8=BF=94=E5=9B=9EEV=5FADD?= =?UTF-8?q?=E4=BA=8B=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- poller_kqueue.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/poller_kqueue.go b/poller_kqueue.go index db1f2969..ddf5ed68 100644 --- a/poller_kqueue.go +++ b/poller_kqueue.go @@ -102,14 +102,14 @@ func (p *poller) trigger() { func (p *poller) addRead(fd int) { p.mux.Lock() - p.eventList = append(p.eventList, syscall.Kevent_t{Ident: uint64(fd), Flags: syscall.EV_ADD, Filter: syscall.EVFILT_READ}) + p.eventList = append(p.eventList, syscall.Kevent_t{Ident: uint64(fd), Flags: syscall.EV_ADD | syscall.EV_CLEAR, Filter: syscall.EVFILT_READ}) p.mux.Unlock() p.trigger() } func (p *poller) modWrite(fd int) { p.mux.Lock() - p.eventList = append(p.eventList, syscall.Kevent_t{Ident: uint64(fd), Flags: syscall.EV_ADD, Filter: syscall.EVFILT_WRITE}) + p.eventList = append(p.eventList, syscall.Kevent_t{Ident: uint64(fd), Flags: syscall.EV_ADD | syscall.EV_CLEAR, Filter: syscall.EVFILT_WRITE}) p.mux.Unlock() p.trigger() } @@ -218,7 +218,7 @@ func (p *poller) readWriteLoop() { defer runtime.UnlockOSThread() } - var events = make([]syscall.Kevent_t, 1024) + events := make([]syscall.Kevent_t, 1024) var changes []syscall.Kevent_t p.shutdown = false @@ -308,5 +308,4 @@ func newPoller(g *Engine, isListener bool, index int) (*poller, error) { } func (c *Conn) ResetPollerEvent() { - }