Add locking mechanism to Result.reduce for thread safety

This commit is contained in:
tsosunchia committed 2025-10-29 11:05:54 +08:00
1 parent 04af30d940
commit d8418d7ec5
1 file changed
+3
+3
View File
@@ -229,6 +229,9 @@ func (s *Result) add(hop Hop, attemptIdx, numMeasurements, maxAttempts int) {
}
func (s *Result) reduce(final int) {
s.lock.Lock()
defer s.lock.Unlock()
if final > 0 && final < len(s.Hops) {
s.Hops = s.Hops[:final]
}