Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修复eventloop中令人疑惑的注释 #124

Merged
merged 1 commit into from
Apr 22, 2022
Merged

Conversation

zbh255
Copy link
Contributor

@zbh255 zbh255 commented Apr 21, 2022

事件循环中这个注释写的是修改为写就绪事件,但是看poller里面是修改为读就绪事件。
从API的描述看来也是注册读事件的意思。

gev/poller/epoll.go

Lines 128 to 131 in 3ac80c5

// EnableRead 修改fd注册事件为可读事件
func (ep *Poller) EnableRead(fd int) error {
return ep.mod(fd, readEvent)
}

gev/poller/kqueue.go

Lines 110 to 124 in 3ac80c5

// EnableRead 修改fd注册事件为可读事件
func (p *Poller) EnableRead(fd int) error {
oldEvents, ok := p.sockets.Load(fd)
if !ok {
return errors.New("sync map load error")
}
newEvents := EventRead
kEvents := p.kEvents(oldEvents.(Event), newEvents, fd)
_, err := unix.Kevent(p.fd, kEvents, nil, nil)
if err != nil {
p.sockets.Store(fd, newEvents)
}
return err
}

@Allenxuxu Allenxuxu merged commit 16e310c into Allenxuxu:master Apr 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants