mirror of https://github.com/docker/docs.git
engine cleanup: Don't mess with the global random.
Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
parent
fe655270b9
commit
f1782fed90
|
@ -32,10 +32,6 @@ const (
|
||||||
minSupportedVersion = version.Version("1.6.0")
|
minSupportedVersion = version.Version("1.6.0")
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
|
||||||
rand.Seed(int64(time.Now().Nanosecond()))
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewEngine is exported
|
// NewEngine is exported
|
||||||
func NewEngine(addr string, overcommitRatio float64) *Engine {
|
func NewEngine(addr string, overcommitRatio float64) *Engine {
|
||||||
e := &Engine{
|
e := &Engine{
|
||||||
|
@ -43,6 +39,7 @@ func NewEngine(addr string, overcommitRatio float64) *Engine {
|
||||||
client: nopclient.NewNopClient(),
|
client: nopclient.NewNopClient(),
|
||||||
Labels: make(map[string]string),
|
Labels: make(map[string]string),
|
||||||
stopCh: make(chan struct{}),
|
stopCh: make(chan struct{}),
|
||||||
|
r: rand.New(rand.NewSource(time.Now().UTC().UnixNano())),
|
||||||
containers: make(map[string]*Container),
|
containers: make(map[string]*Container),
|
||||||
volumes: make(map[string]*Volume),
|
volumes: make(map[string]*Volume),
|
||||||
healthy: true,
|
healthy: true,
|
||||||
|
@ -64,6 +61,7 @@ type Engine struct {
|
||||||
Labels map[string]string
|
Labels map[string]string
|
||||||
|
|
||||||
stopCh chan struct{}
|
stopCh chan struct{}
|
||||||
|
r *rand.Rand
|
||||||
containers map[string]*Container
|
containers map[string]*Container
|
||||||
images []*Image
|
images []*Image
|
||||||
volumes map[string]*Volume
|
volumes map[string]*Volume
|
||||||
|
@ -348,7 +346,7 @@ func (e *Engine) refreshLoop() {
|
||||||
for {
|
for {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
refreshPeriod := time.Duration(rand.Intn(stateRefreshMaxRange-stateRefreshMinRange) + stateRefreshMinRange)
|
refreshPeriod := time.Duration(e.r.Intn(stateRefreshMaxRange-stateRefreshMinRange) + stateRefreshMinRange)
|
||||||
|
|
||||||
// Sleep stateRefreshPeriod or quit if we get stopped.
|
// Sleep stateRefreshPeriod or quit if we get stopped.
|
||||||
select {
|
select {
|
||||||
|
|
Loading…
Reference in New Issue