policer: Fix concurrent map write #969
1 changed files with 8 additions and 1 deletions
|
@ -98,6 +98,13 @@ func (m *errMap) addSeenError(cnr cid.ID, err error) bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m.skipMap[cnr] = append(m.skipMap[cnr], err)
|
|
||||||
|
// Restrict list length to avoid possible OOM if some random error is added in future.
|
||||||
|
const maxErrListLength = 10
|
||||||
|
|
||||||
|
lst := m.skipMap[cnr]
|
||||||
|
if len(lst) < maxErrListLength {
|
||||||
|
m.skipMap[cnr] = append(lst, err)
|
||||||
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue