Skip to content

Commit 90c5517

Browse files
author
Santhosh Manohar
committed
Merge pull request #979 from LK4D4/fix_stats_race
Fix race in Statistics
2 parents 9994ce1 + bc0f59e commit 90c5517

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)