remove unecessary mutex usage in healthchecks

This commit is contained in:
Marco Jantke 2018-01-22 11:32:02 +01:00 committed by Traefiker
parent 5140bbe99a
commit c134dcd6fe

View file

@ -49,7 +49,6 @@ type BackendHealthCheck struct {
//HealthCheck struct //HealthCheck struct
type HealthCheck struct { type HealthCheck struct {
mutex sync.Mutex
Backends map[string]*BackendHealthCheck Backends map[string]*BackendHealthCheck
cancel context.CancelFunc cancel context.CancelFunc
} }
@ -78,14 +77,12 @@ func NewBackendHealthCheck(options Options, backendName string) *BackendHealthCh
//SetBackendsConfiguration set backends configuration //SetBackendsConfiguration set backends configuration
func (hc *HealthCheck) SetBackendsConfiguration(parentCtx context.Context, backends map[string]*BackendHealthCheck) { func (hc *HealthCheck) SetBackendsConfiguration(parentCtx context.Context, backends map[string]*BackendHealthCheck) {
hc.mutex.Lock()
hc.Backends = backends hc.Backends = backends
if hc.cancel != nil { if hc.cancel != nil {
hc.cancel() hc.cancel()
} }
ctx, cancel := context.WithCancel(parentCtx) ctx, cancel := context.WithCancel(parentCtx)
hc.cancel = cancel hc.cancel = cancel
hc.mutex.Unlock()
for _, backend := range backends { for _, backend := range backends {
currentBackend := backend currentBackend := backend