diff --git a/cmd/stayrtr/stayrtr.go b/cmd/stayrtr/stayrtr.go index 1614227..9e8a507 100644 --- a/cmd/stayrtr/stayrtr.go +++ b/cmd/stayrtr/stayrtr.go @@ -59,6 +59,7 @@ var ( EnforceVersion = flag.Bool("enforce.version", false, "Disable version negotiation") DisableBGPSec = flag.Bool("disable.bgpsec", false, "Disable sending out BGPSEC Router Keys") DisableASPA = flag.Bool("disable.aspa", false, "Disable sending out ASPA objects") + EnableNODELAY = flag.Bool("enable.nodelay", false, "Force enable TCP NODELAY (Likely increases CPU)") Bind = flag.String("bind", ":8282", "Bind address") @@ -763,6 +764,7 @@ func run() error { EnforceVersion: *EnforceVersion, DisableBGPSec: *DisableBGPSec, DisableASPA: *DisableASPA, + EnableNODELAY: *EnableNODELAY, } var me *metricsEvent diff --git a/lib/server.go b/lib/server.go index d084ea7..d8740c3 100644 --- a/lib/server.go +++ b/lib/server.go @@ -135,6 +135,7 @@ type Server struct { enforceVersion bool disableBGPSec bool disableASPA bool + enableNODELAY bool sdlock *sync.RWMutex sdListDiff [][]SendableData @@ -158,8 +159,9 @@ type ServerConfiguration struct { SessId int - DisableBGPSec bool - DisableASPA bool + DisableBGPSec bool + DisableASPA bool + EnableNODELAY bool RefreshInterval uint32 RetryInterval uint32 @@ -487,10 +489,8 @@ func (s *Server) Start(bind string) error { return s.loopTCP(tcplist, "tcp", s.acceptClientTCP) } -var EnableNODELAY = flag.Bool("enable.nodelay", false, "Force enable TCP NODELAY (Likely increases CPU)") - func (s *Server) acceptClientTCP(tcpconn net.Conn) error { - if !*EnableNODELAY { + if !s.enableNODELAY { tc, ok := tcpconn.(*net.TCPConn) if ok { tc.SetNoDelay(false)