mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Fix a race condition when running the port allocator
This commit is contained in:
parent
a4fc52305a
commit
d32f184696
1 changed files with 1 additions and 4 deletions
|
@ -167,10 +167,6 @@ type PortAllocator struct {
|
|||
}
|
||||
|
||||
func (alloc *PortAllocator) runFountain() {
|
||||
if alloc.fountain != nil {
|
||||
return
|
||||
}
|
||||
alloc.fountain = make(chan int)
|
||||
for {
|
||||
for port := portRangeStart; port < portRangeEnd; port++ {
|
||||
alloc.fountain <- port
|
||||
|
@ -208,6 +204,7 @@ func (alloc *PortAllocator) Acquire(port int) (int, error) {
|
|||
func newPortAllocator() (*PortAllocator, error) {
|
||||
allocator := &PortAllocator{
|
||||
inUse: make(map[int]struct{}),
|
||||
fountain: make(chan int),
|
||||
}
|
||||
go allocator.runFountain()
|
||||
return allocator, nil
|
||||
|
|
Loading…
Add table
Reference in a new issue