Skip to content

Commit

Permalink
add pd.eh=nullptr check
Browse files Browse the repository at this point in the history
  • Loading branch information
shaovie committed Sep 21, 2023
1 parent d590b0d commit 8cf505e
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions epoll.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,17 @@ func (ep *evPoll) run(wg *sync.WaitGroup) error {
ed := *(**evData)(unsafe.Pointer(&ev.Fd))
// EPOLLHUP refer to man 2 epoll_ctl
if ev.Events&(syscall.EPOLLHUP|syscall.EPOLLERR) != 0 {
eh := ed.eh
ep.remove(ed.fd, EvAll) // MUST before OnClose()
eh.OnClose()
if ed.eh != nil {
eh := ed.eh
ep.remove(ed.fd, EvAll) // MUST before OnClose()
eh.OnClose()
}
continue
}
if ev.Events&(syscall.EPOLLOUT) != 0 { // MUST before EPOLLIN (e.g. connect)
if ed.eh == nil {
continue
}
if ed.eh.OnWrite() == false {
eh := ed.eh
ep.remove(ed.fd, EvAll) // MUST before OnClose()
Expand All @@ -149,6 +154,9 @@ func (ep *evPoll) run(wg *sync.WaitGroup) error {
}
}
if ev.Events&(syscall.EPOLLIN) != 0 {
if ed.eh == nil {
continue
}
if ed.eh.OnRead() == false {
eh := ed.eh
ep.remove(ed.fd, EvAll) // MUST before OnClose()
Expand Down

0 comments on commit 8cf505e

Please sign in to comment.