Skip to content

Commit 6ecb469

Browse files
committed
Fix race condition when using cgroups.Paths
Signed-off-by: Qiang Huang <[email protected]>
1 parent 50f0a2b commit 6ecb469

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

libcontainer/cgroups/fs/apply_raw.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ func (m *Manager) Apply(pid int) (err error) {
104104
if m.Cgroups == nil {
105105
return nil
106106
}
107+
m.mu.Lock()
108+
defer m.mu.Unlock()
107109

108110
var c = m.Cgroups
109111

@@ -128,8 +130,6 @@ func (m *Manager) Apply(pid int) (err error) {
128130
return cgroups.EnterPid(m.Paths, pid)
129131
}
130132

131-
m.mu.Lock()
132-
defer m.mu.Unlock()
133133
paths := make(map[string]string)
134134
for _, sys := range subsystems {
135135
if err := sys.Apply(d); err != nil {

0 commit comments

Comments
 (0)