github.com/angenalZZZ/gofunc@v0.0.0-20210507121333-48ff1be3917b/net/loop_linux.go (about) 1 // +build linux 2 3 package net 4 5 import "github.com/angenalZZZ/gofunc/net/internal/netpoll" 6 7 func (el *eventloop) handleEvent(fd int, ev uint32) error { 8 if c, ok := el.connections[fd]; ok { 9 switch c.outboundBuffer.IsEmpty() { 10 // Don't change the ordering of processing EPOLLOUT | EPOLLRDHUP / EPOLLIN unless you're 100% 11 // sure what you're doing! 12 // Re-ordering can easily introduce bugs and bad side-effects, as I found out painfully in the past. 13 case false: 14 if ev&netpoll.OutEvents != 0 { 15 return el.loopWrite(c) 16 } 17 return nil 18 case true: 19 if ev&netpoll.InEvents != 0 { 20 return el.loopRead(c) 21 } 22 return nil 23 } 24 } 25 return el.loopAccept(fd) 26 }