Skip to content

Commit

Permalink
opt: refine the way to call loadBalancer.calibrate
Browse files Browse the repository at this point in the history
  • Loading branch information
panjf2000 committed Aug 12, 2020
1 parent 8c520a2 commit 9ab678b
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 3 deletions.
1 change: 0 additions & 1 deletion acceptor_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ func (svr *server) acceptNewConnection(fd int) error {
return
}
el.connections[nfd] = c
el.calibrateCallback(el, 1)
err = el.loopOpen(c)
return
})
Expand Down
2 changes: 1 addition & 1 deletion eventloop_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ func (el *eventloop) loopAccept(fd int) error {
c := newTCPConn(nfd, el, sa)
if err = el.poller.AddRead(c.fd); err == nil {
el.connections[c.fd] = c
el.calibrateCallback(el, 1)
return el.loopOpen(c)
}
return err
Expand All @@ -111,6 +110,7 @@ func (el *eventloop) loopOpen(c *conn) error {
_ = netpoll.SetKeepAlive(c.fd, int(el.svr.opts.TCPKeepAlive/time.Second))
}
}
el.calibrateCallback(el, 1)

out, action := el.eventHandler.OnOpened(c)
if out != nil {
Expand Down
2 changes: 1 addition & 1 deletion eventloop_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,13 @@ func (el *eventloop) loopAccept(c *stdConn) error {
el.connections[c] = struct{}{}
c.localAddr = el.svr.ln.lnaddr
c.remoteAddr = c.conn.RemoteAddr()
el.calibrateCallback(el, 1)
if el.svr.opts.TCPKeepAlive > 0 {
if c, ok := c.conn.(*net.TCPConn); ok {
_ = c.SetKeepAlive(true)
_ = c.SetKeepAlivePeriod(el.svr.opts.TCPKeepAlive)
}
}
el.calibrateCallback(el, 1)

out, action := el.eventHandler.OnOpened(c)
if out != nil {
Expand Down

0 comments on commit 9ab678b

Please sign in to comment.