From 2e02967acae23126402560a246bafc16d364a52d Mon Sep 17 00:00:00 2001 From: Kouhei Ueno Date: Wed, 6 Aug 2014 04:34:54 +0900 Subject: [PATCH] Avoid data race in Proxier.OnUpdate The bug was that the proxier is passed as value on method decleration. This caused a copy of Proxier to be created when the method was invoked. The copy being a shallow copy turned out to have them both reference a same map instance, but their mutexes were different instances. This turned out to use different mutexes before operating on a same map instance, which didn't make sense. --- pkg/proxy/proxier.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/proxy/proxier.go b/pkg/proxy/proxier.go index ee16edac634..ca76838b616 100644 --- a/pkg/proxy/proxier.go +++ b/pkg/proxy/proxier.go @@ -193,7 +193,7 @@ func (proxier *Proxier) addServiceCommon(service string, l net.Listener) { // OnUpdate manages the active set of service proxies. // Active service proxies are reinitialized if found in the update set or // shutdown if missing from the update set. -func (proxier Proxier) OnUpdate(services []api.Service) { +func (proxier *Proxier) OnUpdate(services []api.Service) { glog.Infof("Received update notice: %+v", services) activeServices := util.StringSet{} for _, service := range services {