Skip to content

Commit

Permalink
fix kequeue wait time
Browse files Browse the repository at this point in the history
  • Loading branch information
pilot committed Dec 28, 2023
1 parent e2f226e commit 6d8f331
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions kqueue.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,12 @@ func (kq *poll) del(ev *Event) error {
}

func (kq *poll) wait(cb func(ev *Event, res uint32), timeout time.Duration) error {
ts := syscall.NsecToTimespec(timeout.Nanoseconds())
n, err := syscall.Kevent(kq.fd, kq.changes, kq.events, &ts)
var timespec *syscall.Timespec
if timeout >= 0 {
ts := syscall.NsecToTimespec(timeout.Nanoseconds())
timespec = &ts
}
n, err := syscall.Kevent(kq.fd, kq.changes, kq.events, timespec)
if err != nil && !temporaryErr(err) {
return err
}
Expand Down

0 comments on commit 6d8f331

Please sign in to comment.