From ec0c66902e3d3312ca32ad65722df23ed890e576 Mon Sep 17 00:00:00 2001 From: Daniel Dao Date: Mon, 24 Aug 2015 14:47:44 +0000 Subject: [PATCH] lock port mapper when reapply iptables rules Make sure that port mapper state is not updated while we are trying to remap everything. Signed-off-by: Daniel Dao --- portmapper/mapper.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/portmapper/mapper.go b/portmapper/mapper.go index bbdedaa..d125fa8 100644 --- a/portmapper/mapper.go +++ b/portmapper/mapper.go @@ -188,6 +188,8 @@ func (pm *PortMapper) Unmap(host net.Addr) error { //ReMapAll will re-apply all port mappings func (pm *PortMapper) ReMapAll() { + pm.lock.Lock() + defer pm.lock.Unlock() logrus.Debugln("Re-applying all port mappings.") for _, data := range pm.currentMappings { containerIP, containerPort := getIPAndPort(data.container)