Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit ce20a80
Author: xtaci <[email protected]>
Date:   Thu May 6 10:08:16 2021 +0800

    remove defer in hot path
  • Loading branch information
xtaci committed May 6, 2021
1 parent c8179c0 commit e9b1aef
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions aio_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,18 @@ func (p *poller) Close() error {
return p.wakeup()
}

func (p *poller) Watch(fd int) error {
func (p *poller) Watch(fd int) (err error) {
p.mu.Lock()
defer p.mu.Unlock()
return syscall.EpollCtl(p.pfd, syscall.EPOLL_CTL_ADD, int(fd), &syscall.EpollEvent{Fd: int32(fd), Events: syscall.EPOLLONESHOT | syscall.EPOLLRDHUP | syscall.EPOLLIN | syscall.EPOLLOUT | _EPOLLET})
err = syscall.EpollCtl(p.pfd, syscall.EPOLL_CTL_ADD, int(fd), &syscall.EpollEvent{Fd: int32(fd), Events: syscall.EPOLLONESHOT | syscall.EPOLLRDHUP | syscall.EPOLLIN | syscall.EPOLLOUT | _EPOLLET})
p.mu.Unlock()
return
}

func (p *poller) Rearm(fd int) error {
func (p *poller) Rearm(fd int) (err error) {
p.mu.Lock()
defer p.mu.Unlock()
return syscall.EpollCtl(p.pfd, syscall.EPOLL_CTL_MOD, int(fd), &syscall.EpollEvent{Fd: int32(fd), Events: syscall.EPOLLONESHOT | syscall.EPOLLRDHUP | syscall.EPOLLIN | syscall.EPOLLOUT | _EPOLLET})
err = syscall.EpollCtl(p.pfd, syscall.EPOLL_CTL_MOD, int(fd), &syscall.EpollEvent{Fd: int32(fd), Events: syscall.EPOLLONESHOT | syscall.EPOLLRDHUP | syscall.EPOLLIN | syscall.EPOLLOUT | _EPOLLET})
p.mu.Unlock()
return
}

// wakeup interrupt epoll_wait
Expand Down

0 comments on commit e9b1aef

Please sign in to comment.