mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Fix race in Statistics
Signed-off-by: Alexander Morozov <lk4d4@docker.com>
This commit is contained in:
parent
2ffd4a9011
commit
0eb01bbbee
1 changed files with 5 additions and 2 deletions
|
@ -142,12 +142,15 @@ func (sb *sandbox) Labels() map[string]interface{} {
|
||||||
func (sb *sandbox) Statistics() (map[string]*types.InterfaceStatistics, error) {
|
func (sb *sandbox) Statistics() (map[string]*types.InterfaceStatistics, error) {
|
||||||
m := make(map[string]*types.InterfaceStatistics)
|
m := make(map[string]*types.InterfaceStatistics)
|
||||||
|
|
||||||
if sb.osSbox == nil {
|
sb.Lock()
|
||||||
|
osb := sb.osSbox
|
||||||
|
sb.Unlock()
|
||||||
|
if osb == nil {
|
||||||
return m, nil
|
return m, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var err error
|
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 {
|
if m[i.DstName()], err = i.Statistics(); err != nil {
|
||||||
return m, err
|
return m, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue