DockerSwarmSuite lock portIndex to work around race
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit c096225e8e
)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
eeeb2e941d
commit
bf212c5b33
1 changed files with 3 additions and 4 deletions
|
@ -304,8 +304,8 @@ func init() {
|
|||
type DockerSwarmSuite struct {
|
||||
server *httptest.Server
|
||||
ds *DockerSuite
|
||||
daemonsLock sync.Mutex // protect access to daemons and portIndex
|
||||
daemons []*daemon.Daemon
|
||||
daemonsLock sync.Mutex // protect access to daemons
|
||||
portIndex int
|
||||
}
|
||||
|
||||
|
@ -336,8 +336,8 @@ func (s *DockerSwarmSuite) AddDaemon(c *check.C, joinSwarm, manager bool) *daemo
|
|||
d.StartNode(c)
|
||||
}
|
||||
|
||||
s.portIndex++
|
||||
s.daemonsLock.Lock()
|
||||
s.portIndex++
|
||||
s.daemons = append(s.daemons, d)
|
||||
s.daemonsLock.Unlock()
|
||||
|
||||
|
@ -354,9 +354,8 @@ func (s *DockerSwarmSuite) TearDownTest(c *check.C) {
|
|||
}
|
||||
}
|
||||
s.daemons = nil
|
||||
s.daemonsLock.Unlock()
|
||||
|
||||
s.portIndex = 0
|
||||
s.daemonsLock.Unlock()
|
||||
s.ds.TearDownTest(c)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue