Add a deadline for epollwait

This commit is contained in:
tidwall 2020-01-15 15:33:41 -07:00
parent 34ff08a426
commit 399d938449
1 changed files with 2 additions and 2 deletions

View File

@ -54,7 +54,7 @@ func (p *Poll) Trigger(note interface{}) error {
func (p *Poll) Wait(iter func(fd int, note interface{}) error) error { func (p *Poll) Wait(iter func(fd int, note interface{}) error) error {
events := make([]syscall.EpollEvent, 64) events := make([]syscall.EpollEvent, 64)
for { for {
n, err := syscall.EpollWait(p.fd, events, -1) n, err := syscall.EpollWait(p.fd, events, 100)
if err != nil && err != syscall.EINTR { if err != nil && err != syscall.EINTR {
return err return err
} }
@ -69,7 +69,7 @@ func (p *Poll) Wait(iter func(fd int, note interface{}) error) error {
return err return err
} }
} else if fd == p.wfd { } else if fd == p.wfd {
var data [16]byte var data [8]byte
syscall.Read(p.wfd, data[:]) syscall.Read(p.wfd, data[:])
} }
} }