mirror of
https://gitee.com/IrisVega/frp.git
synced 2024-11-01 22:31:29 +08:00
fix: kcp protocol cause delay release resource (#2621)
Co-authored-by: blizard863 <760076784@qq.com>
This commit is contained in:
parent
998e678a7f
commit
1d26ea440b
@ -182,9 +182,16 @@ func (ctl *Control) HandleNewProxyResp(inMsg *msg.NewProxyResp) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ctl *Control) Close() error {
|
func (ctl *Control) Close() error {
|
||||||
|
return ctl.GracefulClose(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ctl *Control) GracefulClose(t time.Duration) error {
|
||||||
ctl.pm.Close()
|
ctl.pm.Close()
|
||||||
ctl.conn.Close()
|
|
||||||
ctl.vm.Close()
|
ctl.vm.Close()
|
||||||
|
|
||||||
|
time.Sleep(t)
|
||||||
|
|
||||||
|
ctl.conn.Close()
|
||||||
if ctl.session != nil {
|
if ctl.session != nil {
|
||||||
ctl.session.Close()
|
ctl.session.Close()
|
||||||
}
|
}
|
||||||
|
@ -311,10 +311,14 @@ func (svr *Service) ReloadConf(pxyCfgs map[string]config.ProxyConf, visitorCfgs
|
|||||||
return svr.ctl.ReloadConf(pxyCfgs, visitorCfgs)
|
return svr.ctl.ReloadConf(pxyCfgs, visitorCfgs)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (svr *Service) Close() {
|
func (svr *Service) Close(t time.Duration) {
|
||||||
atomic.StoreUint32(&svr.exit, 1)
|
atomic.StoreUint32(&svr.exit, 1)
|
||||||
if svr.ctl != nil {
|
if svr.ctl != nil {
|
||||||
|
if t > 0 {
|
||||||
|
svr.ctl.GracefulClose(t)
|
||||||
|
} else {
|
||||||
svr.ctl.Close()
|
svr.ctl.Close()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
svr.cancel()
|
svr.cancel()
|
||||||
}
|
}
|
||||||
|
@ -124,8 +124,7 @@ func handleSignal(svr *client.Service) {
|
|||||||
ch := make(chan os.Signal)
|
ch := make(chan os.Signal)
|
||||||
signal.Notify(ch, syscall.SIGINT, syscall.SIGTERM)
|
signal.Notify(ch, syscall.SIGINT, syscall.SIGTERM)
|
||||||
<-ch
|
<-ch
|
||||||
svr.Close()
|
svr.Close(time.Millisecond * 250)
|
||||||
time.Sleep(250 * time.Millisecond)
|
|
||||||
close(kcpDoneCh)
|
close(kcpDoneCh)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user