@@ -11,12 +11,15 @@ import (
1111 "os/exec"
1212 "strconv"
1313 "strings"
14+ "sync"
1415
1516 "github.com/Azure/azure-container-networking/cns"
1617 "github.com/Azure/azure-container-networking/log"
1718 "github.com/containernetworking/cni/libcni"
1819)
1920
21+ var loopbackOperationLock = & sync.Mutex {}
22+
2023func createOrUpdateInterface (createNetworkContainerRequest cns.CreateNetworkContainerRequest ) error {
2124 // Create Operation is only supported for WebApps only on Windows
2225 if createNetworkContainerRequest .NetworkContainerType != cns .WebApps {
@@ -87,7 +90,10 @@ func setWeakHostOnInterface(ipAddress string) error {
8790
8891 log .Printf ("[Azure CNS] Going to enable weak host send/receive on interface: %v" , args )
8992 c := exec .Command ("cmd" , args ... )
93+
94+ loopbackOperationLock .Lock ()
9095 bytes , err := c .Output ()
96+ loopbackOperationLock .Unlock ()
9197
9298 if err == nil {
9399 log .Printf ("[Azure CNS] Successfully updated weak host send/receive on interface %v.\n " , string (bytes ))
@@ -136,7 +142,10 @@ func createOrUpdateWithOperation(createNetworkContainerRequest cns.CreateNetwork
136142
137143 log .Printf ("[Azure CNS] Going to create/update network loopback adapter: %v" , args )
138144 c := exec .Command ("cmd" , args ... )
145+
146+ loopbackOperationLock .Lock ()
139147 bytes , err := c .Output ()
148+ loopbackOperationLock .Unlock ()
140149
141150 if err == nil {
142151 log .Printf ("[Azure CNS] Successfully created network loopback adapter %v.\n " , string (bytes ))
@@ -167,7 +176,10 @@ func deleteInterface(networkContainerID string) error {
167176
168177 log .Printf ("[Azure CNS] Going to delete network loopback adapter: %v" , args )
169178 c := exec .Command ("cmd" , args ... )
179+
180+ loopbackOperationLock .Lock ()
170181 bytes , err := c .Output ()
182+ loopbackOperationLock .Unlock ()
171183
172184 if err == nil {
173185 log .Printf ("[Azure CNS] Successfully deleted network container %v.\n " , string (bytes ))
0 commit comments