This repository was archived by the owner on Oct 13, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed
components/engine/container Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change 11package container
22
33import (
4+ "sync"
5+
46 "github.com/docker/docker/api/types"
57 "github.com/sirupsen/logrus"
68)
@@ -9,6 +11,7 @@ import (
911type Health struct {
1012 types.Health
1113 stop chan struct {} // Write struct{} to stop the monitor
14+ mu sync.Mutex
1215}
1316
1417// String returns a human-readable description of the health-check state
@@ -26,9 +29,12 @@ func (s *Health) String() string {
2629 }
2730}
2831
29- // OpenMonitorChannel creates and returns a new monitor channel. If there already is one,
30- // it returns nil.
32+ // OpenMonitorChannel creates and returns a new monitor channel. If there
33+ // already is one, it returns nil.
3134func (s * Health ) OpenMonitorChannel () chan struct {} {
35+ s .mu .Lock ()
36+ defer s .mu .Unlock ()
37+
3238 if s .stop == nil {
3339 logrus .Debug ("OpenMonitorChannel" )
3440 s .stop = make (chan struct {})
@@ -39,6 +45,9 @@ func (s *Health) OpenMonitorChannel() chan struct{} {
3945
4046// CloseMonitorChannel closes any existing monitor channel.
4147func (s * Health ) CloseMonitorChannel () {
48+ s .mu .Lock ()
49+ defer s .mu .Unlock ()
50+
4251 if s .stop != nil {
4352 logrus .Debug ("CloseMonitorChannel: waiting for probe to stop" )
4453 close (s .stop )
You can’t perform that action at this time.
0 commit comments