From f1a51eba18a85649122006289f5ac9c8a62b8c6e Mon Sep 17 00:00:00 2001 From: fatedier Date: Tue, 19 Oct 2021 15:02:45 +0800 Subject: [PATCH] client: lint --- client/control.go | 4 ++-- client/service.go | 12 ++++++------ cmd/frpc/sub/root.go | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/client/control.go b/client/control.go index 9bf31098..067fe37f 100644 --- a/client/control.go +++ b/client/control.go @@ -185,11 +185,11 @@ func (ctl *Control) Close() error { return ctl.GracefulClose(0) } -func (ctl *Control) GracefulClose(t time.Duration) error { +func (ctl *Control) GracefulClose(d time.Duration) error { ctl.pm.Close() ctl.vm.Close() - time.Sleep(t) + time.Sleep(d) ctl.conn.Close() if ctl.session != nil { diff --git a/client/service.go b/client/service.go index 4af6e07f..8b880034 100644 --- a/client/service.go +++ b/client/service.go @@ -311,14 +311,14 @@ func (svr *Service) ReloadConf(pxyCfgs map[string]config.ProxyConf, visitorCfgs return svr.ctl.ReloadConf(pxyCfgs, visitorCfgs) } -func (svr *Service) Close(t time.Duration) { +func (svr *Service) Close() { + svr.GracefulClose(time.Duration(0)) +} + +func (svr *Service) GracefulClose(d time.Duration) { atomic.StoreUint32(&svr.exit, 1) if svr.ctl != nil { - if t > 0 { - svr.ctl.GracefulClose(t) - } else { - svr.ctl.Close() - } + svr.ctl.GracefulClose(d) } svr.cancel() } diff --git a/cmd/frpc/sub/root.go b/cmd/frpc/sub/root.go index 3c56cead..d03cdd12 100644 --- a/cmd/frpc/sub/root.go +++ b/cmd/frpc/sub/root.go @@ -124,7 +124,7 @@ func handleSignal(svr *client.Service) { ch := make(chan os.Signal) signal.Notify(ch, syscall.SIGINT, syscall.SIGTERM) <-ch - svr.Close(time.Millisecond * 250) + svr.GracefulClose(500 * time.Millisecond) close(kcpDoneCh) }