From e9241aeb943d903ffe82a23ac516d703f8675741 Mon Sep 17 00:00:00 2001 From: fatedier Date: Mon, 19 Mar 2018 20:22:15 +0800 Subject: [PATCH] udp proxy: fix #652 --- models/proto/udp/udp.go | 1 + server/control.go | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/models/proto/udp/udp.go b/models/proto/udp/udp.go index fe548f1..15ecb9c 100644 --- a/models/proto/udp/udp.go +++ b/models/proto/udp/udp.go @@ -82,6 +82,7 @@ func Forwarder(dstAddr *net.UDPAddr, readCh <-chan *msg.UdpPacket, sendCh chan<- mu.Lock() delete(udpConnMap, addr) mu.Unlock() + udpConn.Close() }() buf := pool.GetBuf(1500) diff --git a/server/control.go b/server/control.go index dbb99ad..d7938e7 100644 --- a/server/control.go +++ b/server/control.go @@ -265,13 +265,14 @@ func (ctl *Control) stoper() { ctl.conn.Close() ctl.readerShutdown.WaitDone() + ctl.mu.Lock() + defer ctl.mu.Unlock() + close(ctl.workConnCh) for workConn := range ctl.workConnCh { workConn.Close() } - ctl.mu.Lock() - defer ctl.mu.Unlock() for _, pxy := range ctl.proxies { pxy.Close() ctl.svr.DelProxy(pxy.GetName()) @@ -303,6 +304,7 @@ func (ctl *Control) manager() { if time.Since(ctl.lastPing) > time.Duration(config.ServerCommonCfg.HeartBeatTimeout)*time.Second { ctl.conn.Warn("heartbeat timeout") ctl.allShutdown.Start() + return } case rawMsg, ok := <-ctl.readCh: if !ok {