We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
func (svr *server) acceptNewConnection(fd int) error { nfd, sa, err := unix.Accept(fd) if err != nil { if err == unix.EAGAIN { return nil } return err } if err := unix.SetNonblock(nfd, true); err != nil { return err } lp := svr.subLoopGroup.next() //可以从pool里面取出来,重置一些参数就行,不然在高并发下对象和ringbuffer的消耗还是挺大的 c := &conn{ fd: nfd, sa: sa, loop: lp, inboundBuffer: ringbuffer.New(socketRingBufferSize), outboundBuffer: ringbuffer.New(socketRingBufferSize), } _ = lp.loopOpen(c) _ = lp.poller.Trigger(func() (err error) { if err = lp.poller.AddRead(nfd); err == nil { lp.connections[nfd] = c return } return }) return nil }
The text was updated successfully, but these errors were encountered:
你是说用一个临时对象池 sync.Pool 来 cache conn?连接关闭之后放回 pool,下次新建连接直接从 pool 取?
sync.Pool
conn
Sorry, something went wrong.
Set up a connections pool
a6e43c8
Fix #27
4cc2f96
05369ea
Fix panjf2000#27
panjf2000
No branches or pull requests
The text was updated successfully, but these errors were encountered: