From 34ec7bd1c9f6ede9f2ba7d905678486304e94b2e Mon Sep 17 00:00:00 2001 From: Martynas Pumputis Date: Mon, 8 May 2017 23:31:10 +0300 Subject: [PATCH] Do not populate network info map in plugin-v2 Avoids unnecessary locking. --- plugin/net/driver.go | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/plugin/net/driver.go b/plugin/net/driver.go index ede1f7a9..e5f78124 100644 --- a/plugin/net/driver.go +++ b/plugin/net/driver.go @@ -194,12 +194,7 @@ func (driver *driver) JoinEndpoint(j *api.JoinRequest) (*api.JoinResponse, error } func (driver *driver) findNetworkInfo(id string) (network, error) { - driver.Lock() - network, found := driver.networks[id] - driver.Unlock() - if found { - return network, nil - } + var network network // plugin-v2 does not have access to docker.sock, so we cannot call Docker // API for the network info. @@ -208,10 +203,13 @@ func (driver *driver) findNetworkInfo(id string) (network, error) { network.isOurs = true network.hasMulticastRoute = driver.forceMulticast - driver.Lock() - driver.networks[id] = network - driver.Unlock() + return network, nil + } + driver.Lock() + network, found := driver.networks[id] + driver.Unlock() + if found { return network, nil }