diff --git a/8_server_workerpool/epoll_linux.go b/8_server_workerpool/epoll_linux.go index 259af2d..ecc5ee3 100755 --- a/8_server_workerpool/epoll_linux.go +++ b/8_server_workerpool/epoll_linux.go @@ -33,7 +33,8 @@ func MkEpoll() (*epoll, error) { func (e *epoll) Add(conn net.Conn) error { // Extract file descriptor associated with the connection fd := socketFD(conn) - err := unix.EpollCtl(e.fd, syscall.EPOLL_CTL_ADD, fd, &unix.EpollEvent{Events: unix.POLLIN | unix.POLLHUP, Fd: int32(fd)}) + //默认是水平触发,这样在未得到处理之前会不断被触发放到workpoll,需要设置为边沿触发 + err := unix.EpollCtl(e.fd, syscall.EPOLL_CTL_ADD, fd, &unix.EpollEvent{Events: unix.POLLIN | unix.POLLHUP | unix.EPOLLET, Fd: int32(fd)}) if err != nil { return err }