Skip to content

Commit

Permalink
fix: data races when accessing `github.com/fatedier/frp/client.(*Serv…
Browse files Browse the repository at this point in the history
…ice).ctl` (fatedier#2891)

* fix: data race in client/service.go

* review fixes
  • Loading branch information
coadler authored Apr 14, 2022
1 parent a7a4ba2 commit 6481870
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions client/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,8 @@ func (svr *Service) ReloadConf(pxyCfgs map[string]config.ProxyConf, visitorCfgs
svr.visitorCfgs = visitorCfgs
svr.cfgMu.Unlock()

svr.ctlMu.RLock()
defer svr.ctlMu.RUnlock()
return svr.ctl.ReloadConf(pxyCfgs, visitorCfgs)
}

Expand All @@ -365,8 +367,12 @@ func (svr *Service) Close() {

func (svr *Service) GracefulClose(d time.Duration) {
atomic.StoreUint32(&svr.exit, 1)

svr.ctlMu.RLock()
if svr.ctl != nil {
svr.ctl.GracefulClose(d)
}
svr.ctlMu.RUnlock()

svr.cancel()
}

0 comments on commit 6481870

Please sign in to comment.