Skip to content

Commit 0c6733d

Browse files
authored
Merge pull request #970 from hqhq/fix_race_cgroup_paths
Fix race condition when using cgroups.Paths
2 parents 31d51c1 + 6ecb469 commit 0c6733d

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)