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

Commit 5b85c88

Browse files
committed
XPod.SandboxNameLocked: new function
Some caller call XPod.SandboxName with p.statusLock. So add XPod.SandboxNameLocked. Signed-off-by: Hui Zhu <teawater@hyper.sh>
1 parent 9021a93 commit 5b85c88

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

daemon/pod/pod.go

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,19 @@ func (p *XPod) Name() string {
101101
return p.name
102102
}
103103

104-
// SandboxName() returns the id of the sandbox, the detail of sandbox should be wrapped inside XPod, this method is
105-
// used for list/display only.
106-
func (p *XPod) SandboxName() string {
104+
func (p *XPod) SandboxNameLocked() string {
107105
var sbn = ""
108-
p.statusLock.RLock()
109106
if p.sandbox != nil {
110107
sbn = p.sandbox.Id
111108
}
109+
return sbn
110+
}
111+
112+
// SandboxName() returns the id of the sandbox, the detail of sandbox should be wrapped inside XPod, this method is
113+
// used for list/display only.
114+
func (p *XPod) SandboxName() string {
115+
p.statusLock.RLock()
116+
sbn := p.SandboxNameLocked()
112117
p.statusLock.RUnlock()
113118
return sbn
114119
}
@@ -171,7 +176,7 @@ func (p *XPod) BriefStatus() (s *apitypes.PodListResult) {
171176
s = &apitypes.PodListResult{
172177
PodID: p.Id(),
173178
PodName: p.Name(),
174-
VmID: p.SandboxName(),
179+
VmID: p.SandboxNameLocked(),
175180
CreatedAt: p.info.CreatedAt,
176181
Labels: p.labels,
177182
}
@@ -207,7 +212,7 @@ func (p *XPod) SandboxBriefStatus() (s *apitypes.VMListResult) {
207212
p.statusLock.RLock()
208213
if p.sandbox != nil {
209214
s = &apitypes.VMListResult{
210-
VmID: p.SandboxName(),
215+
VmID: p.SandboxNameLocked(),
211216
PodID: p.Id(),
212217
}
213218
if p.status == S_POD_PAUSED {

0 commit comments

Comments
 (0)