diff --git a/epoll.go b/epoll.go index b276d02..a0f0608 100644 --- a/epoll.go +++ b/epoll.go @@ -40,16 +40,15 @@ type poll struct { } func openPoll() (*poll, error) { + ep := new(poll) fd, err := syscall.EpollCreate1(0) if err != nil { return nil, err } - - return &poll{ - fd: fd, - fdEvents: make(map[int]*fdEvent), - events: make([]syscall.EpollEvent, initialNEvent), - }, nil + ep.fd = fd + ep.fdEvents = make(map[int]*fdEvent, initialNEvent) + ep.events = make([]syscall.EpollEvent, initialNEvent) + return ep, nil } func (ep *poll) add(ev *Event) error { diff --git a/event.go b/event.go index 257f10f..16a16e5 100644 --- a/event.go +++ b/event.go @@ -275,6 +275,7 @@ func (bs *EventBase) handleActiveEvents() { for e := bs.activeEvLists[i].front(); e != nil; { next := e.nextEle() ev := e.value + e = next if ev.events&EvPersist != 0 { bs.eventQueueRemove(ev, evListActive) if ev.events&EvTimeout != 0 { @@ -285,7 +286,6 @@ func (bs *EventBase) handleActiveEvents() { } else { bs.delEvent(ev) } - e = next ev.cb(ev.fd, ev.res, ev.arg) } } diff --git a/kqueue.go b/kqueue.go index e6ab083..ef7c75d 100644 --- a/kqueue.go +++ b/kqueue.go @@ -25,16 +25,15 @@ type poll struct { } func openPoll() (*poll, error) { + kq := new(poll) fd, err := syscall.Kqueue() if err != nil { return nil, err } - - return &poll{ - fd: fd, - changes: make([]syscall.Kevent_t, initialNEvent), - events: make([]syscall.Kevent_t, initialNEvent), - }, nil + kq.fd = fd + kq.changes = make([]syscall.Kevent_t, initialNEvent) + kq.events = make([]syscall.Kevent_t, initialNEvent) + return kq, nil } func (kq *poll) add(ev *Event) error {