mirror of https://github.com/ehang-io/nps
Stop tickers to free up resources (#263)
parent
bdf12fe22a
commit
88dcea59ec
|
@ -342,6 +342,7 @@ func (s *Bridge) SendLinkInfo(clientId int, link *conn.Link, t *file.Tunnel) (ta
|
||||||
|
|
||||||
func (s *Bridge) ping() {
|
func (s *Bridge) ping() {
|
||||||
ticker := time.NewTicker(time.Second * 5)
|
ticker := time.NewTicker(time.Second * 5)
|
||||||
|
defer ticker.Stop()
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-ticker.C:
|
case <-ticker.C:
|
||||||
|
|
|
@ -369,6 +369,7 @@ func sendP2PTestMsg(localConn *net.UDPConn, remoteAddr1, remoteAddr2, remoteAddr
|
||||||
}
|
}
|
||||||
logs.Trace("try send test packet to target %s", addr)
|
logs.Trace("try send test packet to target %s", addr)
|
||||||
ticker := time.NewTicker(time.Millisecond * 500)
|
ticker := time.NewTicker(time.Millisecond * 500)
|
||||||
|
defer ticker.Stop()
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-ticker.C:
|
case <-ticker.C:
|
||||||
|
@ -394,6 +395,7 @@ func sendP2PTestMsg(localConn *net.UDPConn, remoteAddr1, remoteAddr2, remoteAddr
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ticker := time.NewTicker(time.Second * 2)
|
ticker := time.NewTicker(time.Second * 2)
|
||||||
|
defer ticker.Stop()
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-ticker.C:
|
case <-ticker.C:
|
||||||
|
|
|
@ -117,6 +117,7 @@ func StartLocalServer(l *config.LocalServer, config *config.CommonConfig) error
|
||||||
|
|
||||||
func handleUdpMonitor(config *config.CommonConfig, l *config.LocalServer) {
|
func handleUdpMonitor(config *config.CommonConfig, l *config.LocalServer) {
|
||||||
ticker := time.NewTicker(time.Second * 1)
|
ticker := time.NewTicker(time.Second * 1)
|
||||||
|
defer ticker.Stop()
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-ticker.C:
|
case <-ticker.C:
|
||||||
|
|
|
@ -173,9 +173,9 @@ func (s *Mux) ping() {
|
||||||
s.sendInfo(common.MUX_PING_FLAG, common.MUX_PING, now)
|
s.sendInfo(common.MUX_PING_FLAG, common.MUX_PING, now)
|
||||||
// send the ping flag and get the latency first
|
// send the ping flag and get the latency first
|
||||||
ticker := time.NewTicker(time.Second * 5)
|
ticker := time.NewTicker(time.Second * 5)
|
||||||
|
defer ticker.Stop()
|
||||||
for {
|
for {
|
||||||
if s.IsClose {
|
if s.IsClose {
|
||||||
ticker.Stop()
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
select {
|
select {
|
||||||
|
@ -198,6 +198,7 @@ func (s *Mux) ping() {
|
||||||
}
|
}
|
||||||
atomic.AddUint32(&s.pingOk, 1)
|
atomic.AddUint32(&s.pingOk, 1)
|
||||||
}
|
}
|
||||||
|
return
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -109,6 +109,7 @@ func StartNewServer(bridgePort int, cnf *file.Tunnel, bridgeType string) {
|
||||||
|
|
||||||
func dealClientFlow() {
|
func dealClientFlow() {
|
||||||
ticker := time.NewTicker(time.Minute)
|
ticker := time.NewTicker(time.Minute)
|
||||||
|
defer ticker.Stop()
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-ticker.C:
|
case <-ticker.C:
|
||||||
|
@ -430,6 +431,7 @@ func GetDashboardData() map[string]interface{} {
|
||||||
|
|
||||||
func flowSession(m time.Duration) {
|
func flowSession(m time.Duration) {
|
||||||
ticker := time.NewTicker(m)
|
ticker := time.NewTicker(m)
|
||||||
|
defer ticker.Stop()
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-ticker.C:
|
case <-ticker.C:
|
||||||
|
|
Loading…
Reference in New Issue