Skip to content

Commit

Permalink
client: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
fatedier committed Oct 19, 2021
1 parent 1d26ea4 commit f1a51eb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions client/control.go
Expand Up @@ -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 {
Expand Down
12 changes: 6 additions & 6 deletions client/service.go
Expand Up @@ -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()
}
2 changes: 1 addition & 1 deletion cmd/frpc/sub/root.go
Expand Up @@ -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)
}

Expand Down

0 comments on commit f1a51eb

Please sign in to comment.