Skip to content
Snippets Groups Projects
Commit 8473f488 authored by Pea Nut's avatar Pea Nut Committed by jkito
Browse files

[v5] Quickfix for devision by 0 in updateLocationQualityMap

In some cases the normalized quality is NaN. Then, the json (application
state) can not be decoded and everything fails:
INF avgRttNormalized := (rtt - minAvgRtt) / (maxAvgRtt - minAvgRtt)
INF avgRttNormalized := (126 - 126) / (126 - 126) => NaN
This will be fixed in a nice way in the future when we decided more
about gateway selection (and mybe have a quality given by menshen)
parent ae0d98fc
No related branches found
No related tags found
1 merge request!279Update bitmask-core to send invite token
Pipeline #262802 passed
......@@ -141,6 +141,9 @@ func (m *Menshen) updateLocationQualityMap(transport string) {
// normalize values (from rtt in ms to a number between 0 and 1)
for location, rtt := range qualityMap {
avgRttNormalized := (rtt - minAvgRtt) / (maxAvgRtt - minAvgRtt)
if math.IsNaN(avgRttNormalized) {
avgRttNormalized = 0
}
// higher latency is bad, so 1 - avgRttNormalized
qualityMap[location] = 1 - avgRttNormalized
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment