Skip to content
This repository was archived by the owner on Feb 8, 2021. It is now read-only.

Commit a217e06

Browse files
authored
Merge pull request #711 from teawater/xpodstats
XPod.Stats: fix 2 issues that will make hyperd crash
2 parents 9021a93 + aec1c27 commit a217e06

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

daemon/pod/pod.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -293,17 +293,18 @@ func (p *XPod) ContainerInfo(cid string) (*apitypes.ContainerInfo, error) {
293293
}
294294

295295
func (p *XPod) Stats() *runvtypes.PodStats {
296-
//use channel, don't block in statusLock
296+
//use channel, don't block in resourceLock
297297
ch := make(chan *runvtypes.PodStats, 1)
298298

299-
p.statusLock.Lock()
299+
p.resourceLock.Lock()
300300
if p.sandbox == nil {
301301
ch <- nil
302+
} else {
303+
go func(sb *hypervisor.Vm) {
304+
ch <- sb.Stats()
305+
}(p.sandbox)
302306
}
303-
go func(sb *hypervisor.Vm) {
304-
ch <- sb.Stats()
305-
}(p.sandbox)
306-
p.statusLock.Unlock()
307+
p.resourceLock.Unlock()
307308

308309
return <-ch
309310
}

0 commit comments

Comments
 (0)