Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
| ... | ... |
@@ -1,11 +1,18 @@ |
| 1 | 1 |
package libcontainerd |
| 2 | 2 |
|
| 3 |
+import ( |
|
| 4 |
+ "sync" |
|
| 5 |
+) |
|
| 6 |
+ |
|
| 3 | 7 |
// pauseMonitor is helper to get notifications from pause state changes. |
| 4 | 8 |
type pauseMonitor struct {
|
| 9 |
+ sync.Mutex |
|
| 5 | 10 |
waiters map[string][]chan struct{}
|
| 6 | 11 |
} |
| 7 | 12 |
|
| 8 | 13 |
func (m *pauseMonitor) handle(t string) {
|
| 14 |
+ m.Lock() |
|
| 15 |
+ defer m.Unlock() |
|
| 9 | 16 |
if m.waiters == nil {
|
| 10 | 17 |
return |
| 11 | 18 |
} |
| ... | ... |
@@ -20,6 +27,8 @@ func (m *pauseMonitor) handle(t string) {
|
| 20 | 20 |
} |
| 21 | 21 |
|
| 22 | 22 |
func (m *pauseMonitor) append(t string, waiter chan struct{}) {
|
| 23 |
+ m.Lock() |
|
| 24 |
+ defer m.Unlock() |
|
| 23 | 25 |
if m.waiters == nil {
|
| 24 | 26 |
m.waiters = make(map[string][]chan struct{})
|
| 25 | 27 |
} |