Skip to content

Commit e9b1aef

Browse files
committed
Squashed commit of the following:
commit ce20a80 Author: xtaci <[email protected]> Date: Thu May 6 10:08:16 2021 +0800 remove defer in hot path
1 parent c8179c0 commit e9b1aef

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

aio_linux.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,16 +92,18 @@ func (p *poller) Close() error {
9292
return p.wakeup()
9393
}
9494

95-
func (p *poller) Watch(fd int) error {
95+
func (p *poller) Watch(fd int) (err error) {
9696
p.mu.Lock()
97-
defer p.mu.Unlock()
98-
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})
97+
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})
98+
p.mu.Unlock()
99+
return
99100
}
100101

101-
func (p *poller) Rearm(fd int) error {
102+
func (p *poller) Rearm(fd int) (err error) {
102103
p.mu.Lock()
103-
defer p.mu.Unlock()
104-
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})
104+
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})
105+
p.mu.Unlock()
106+
return
105107
}
106108

107109
// wakeup interrupt epoll_wait

0 commit comments

Comments
 (0)