From 169a870afe7673e11f588bc714085d805d8094a9 Mon Sep 17 00:00:00 2001 From: zhouyang01 Date: Mon, 24 Jun 2019 11:14:43 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E8=BE=B9=E6=B2=BF=E8=A7=A6?= =?UTF-8?q?=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 8_server_workerpool/epoll_linux.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 }