Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Commit

Permalink
Do not populate network info map in plugin-v2
Browse files Browse the repository at this point in the history
Avoids unnecessary locking.
  • Loading branch information
brb committed May 8, 2017
1 parent d5d45de commit 34ec7bd
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions plugin/net/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
}

Expand Down

0 comments on commit 34ec7bd

Please sign in to comment.