review fixes

This commit is contained in:
Colin Adler 2022-04-14 02:48:40 +00:00
parent c89c1943e4
commit 9590d69297

View File

@ -174,10 +174,7 @@ func (svr *Service) keepControllerWorking() {
reconnectCounts := 1 reconnectCounts := 1
for { for {
svr.ctlMu.RLock() <-svr.ctl.ClosedDoneCh()
ctlCh := svr.ctl.ClosedDoneCh()
svr.ctlMu.RUnlock()
<-ctlCh
if atomic.LoadUint32(&svr.exit) != 0 { if atomic.LoadUint32(&svr.exit) != 0 {
return return
} }
@ -359,8 +356,8 @@ func (svr *Service) ReloadConf(pxyCfgs map[string]config.ProxyConf, visitorCfgs
svr.visitorCfgs = visitorCfgs svr.visitorCfgs = visitorCfgs
svr.cfgMu.Unlock() svr.cfgMu.Unlock()
svr.ctlMu.Lock() svr.ctlMu.RLock()
defer svr.ctlMu.Unlock() defer svr.ctlMu.RUnlock()
return svr.ctl.ReloadConf(pxyCfgs, visitorCfgs) return svr.ctl.ReloadConf(pxyCfgs, visitorCfgs)
} }
@ -371,11 +368,11 @@ func (svr *Service) Close() {
func (svr *Service) GracefulClose(d time.Duration) { func (svr *Service) GracefulClose(d time.Duration) {
atomic.StoreUint32(&svr.exit, 1) atomic.StoreUint32(&svr.exit, 1)
svr.ctlMu.Lock() svr.ctlMu.RLock()
if svr.ctl != nil { if svr.ctl != nil {
svr.ctl.GracefulClose(d) svr.ctl.GracefulClose(d)
} }
svr.ctlMu.Unlock() svr.ctlMu.RUnlock()
svr.cancel() svr.cancel()
} }