Skip to content

Commit bc0f59e

Browse files
committed
Fix race in Statistics
Signed-off-by: Alexander Morozov <lk4d4@docker.com>
1 parent 9994ce1 commit bc0f59e

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

sandbox.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,15 @@ func (sb *sandbox) Labels() map[string]interface{} {
142142
func (sb *sandbox) Statistics() (map[string]*types.InterfaceStatistics, error) {
143143
m := make(map[string]*types.InterfaceStatistics)
144144

145-
if sb.osSbox == nil {
145+
sb.Lock()
146+
osb := sb.osSbox
147+
sb.Unlock()
148+
if osb == nil {
146149
return m, nil
147150
}
148151

149152
var err error
150-
for _, i := range sb.osSbox.Info().Interfaces() {
153+
for _, i := range osb.Info().Interfaces() {
151154
if m[i.DstName()], err = i.Statistics(); err != nil {
152155
return m, err
153156
}

0 commit comments

Comments
 (0)