Skip to content

Commit

Permalink
epoll: ET without ONESHOT add events once only
Browse files Browse the repository at this point in the history
  • Loading branch information
lesismal committed Jun 24, 2024
1 parent c2c78ac commit a679c63
Showing 1 changed file with 39 additions and 29 deletions.
68 changes: 39 additions & 29 deletions poller_epoll.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,21 +328,25 @@ func (p *poller) resetRead(fd int) error {
func (p *poller) setRead(op int, fd int) error {
switch p.g.EpollMod {
case EPOLLET:
return syscall.EpollCtl(
p.epfd,
op,
fd,
&syscall.EpollEvent{
Fd: int32(fd),
Events: syscall.EPOLLERR |
syscall.EPOLLHUP |
syscall.EPOLLRDHUP |
syscall.EPOLLPRI |
syscall.EPOLLIN |
EPOLLET |
p.g.EPOLLONESHOT,
},
)
events := syscall.EPOLLERR |
syscall.EPOLLHUP |
syscall.EPOLLRDHUP |
syscall.EPOLLPRI |
syscall.EPOLLIN |
EPOLLET |
p.g.EPOLLONESHOT
if p.g.EPOLLONESHOT != EPOLLONESHOT {
if op == syscall.EPOLL_CTL_ADD {
return syscall.EpollCtl(p.epfd, op, fd, &syscall.EpollEvent{
Fd: int32(fd),
Events: events | syscall.EPOLLOUT,
})
}
}
return syscall.EpollCtl(p.epfd, op, fd, &syscall.EpollEvent{
Fd: int32(fd),
Events: events,
})
default:
return syscall.EpollCtl(
p.epfd,
Expand Down Expand Up @@ -371,20 +375,26 @@ func (p *poller) addReadWrite(fd int) error {
func (p *poller) setReadWrite(op int, fd int) error {
switch p.g.EpollMod {
case EPOLLET:
return syscall.EpollCtl(
p.epfd, op, fd,
&syscall.EpollEvent{
Fd: int32(fd),
Events: syscall.EPOLLERR |
syscall.EPOLLHUP |
syscall.EPOLLRDHUP |
syscall.EPOLLPRI |
syscall.EPOLLIN |
syscall.EPOLLOUT |
EPOLLET |
p.g.EPOLLONESHOT,
},
)
events := syscall.EPOLLERR |
syscall.EPOLLHUP |
syscall.EPOLLRDHUP |
syscall.EPOLLPRI |
syscall.EPOLLIN |
syscall.EPOLLOUT |
EPOLLET |
p.g.EPOLLONESHOT
if p.g.EPOLLONESHOT != EPOLLONESHOT {
if op == syscall.EPOLL_CTL_ADD {
return syscall.EpollCtl(p.epfd, op, fd, &syscall.EpollEvent{
Fd: int32(fd),
Events: events,
})
}
}
return syscall.EpollCtl(p.epfd, op, fd, &syscall.EpollEvent{
Fd: int32(fd),
Events: events,
})
default:
return syscall.EpollCtl(
p.epfd, op, fd,
Expand Down

0 comments on commit a679c63

Please sign in to comment.