浏览代码

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 <dqminh@cloudflare.com>
Daniel Dao 10 年之前
父节点
当前提交
44cb162f3d
共有 1 个文件被更改,包括 2 次插入0 次删除
  1. 2 0
      libnetwork/portmapper/mapper.go

+ 2 - 0
libnetwork/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)