Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion poll_default_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,12 @@ func (p *defaultPoll) Trigger() error {

// Control implements Poll.
func (p *defaultPoll) Control(operator *FDOperator, event PollEvent) error {
// DON'T move `fd=operator.FD` behind inuse() call, we can only access operator before op.inuse() for avoid race
// G1: G2:
// op.inuse() op.unused()
// op.FD -- T1 op.FD = 0 -- T2
// T1 and T2 may happen together
var fd = operator.FD
var op int
var evt epollevent
p.setOperator(unsafe.Pointer(&evt.data), operator)
Expand All @@ -256,5 +262,5 @@ func (p *defaultPoll) Control(operator *FDOperator, event PollEvent) error {
case PollRW2R: // connection wait read
op, evt.events = syscall.EPOLL_CTL_MOD, syscall.EPOLLIN|syscall.EPOLLRDHUP|syscall.EPOLLERR
}
return EpollCtl(p.fd, op, operator.FD, &evt)
return EpollCtl(p.fd, op, fd, &evt)
}