From 0eb01bbbee8a2dc22493628da67b80c78ab29a07 Mon Sep 17 00:00:00 2001 From: Alexander Morozov Date: Mon, 29 Feb 2016 09:45:15 -0800 Subject: [PATCH] Fix race in Statistics Signed-off-by: Alexander Morozov --- libnetwork/sandbox.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libnetwork/sandbox.go b/libnetwork/sandbox.go index c33f4e68da..b8b0509360 100644 --- a/libnetwork/sandbox.go +++ b/libnetwork/sandbox.go @@ -142,12 +142,15 @@ func (sb *sandbox) Labels() map[string]interface{} { func (sb *sandbox) Statistics() (map[string]*types.InterfaceStatistics, error) { m := make(map[string]*types.InterfaceStatistics) - if sb.osSbox == nil { + sb.Lock() + osb := sb.osSbox + sb.Unlock() + if osb == nil { return m, nil } var err error - for _, i := range sb.osSbox.Info().Interfaces() { + for _, i := range osb.Info().Interfaces() { if m[i.DstName()], err = i.Statistics(); err != nil { return m, err }