mirror of
https://github.com/nxtrace/NTrace-core.git
synced 2026-11-28 23:50:34 +00:00
Add locking mechanism to Result.reduce for thread safety
This commit is contained in:
1 parent
04af30d940
commit
d8418d7ec5
1 file changed
+3
@@ -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]
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user