Merge pull request #979 from LK4D4/fix_stats_race

Fix race in Statistics
This commit is contained in:
Santhosh Manohar 2016-02-29 10:37:27 -08:00
commit 450e8e24a1

View file

@ -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
}