[#969] policer: Restrict the number of remembered errors

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
Evgenii Stratonikov 2024-02-08 10:05:02 +03:00
parent 6010dfdf3d
commit c3fa902780

View file

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