Skip to content

Commit 2cad173

Browse files
Add synchronization
1 parent dbb8ce3 commit 2cad173

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lib/mongo/server/round_trip_time_calculator.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ def initialize
3535
@last_round_trip_time = nil
3636
@average_round_trip_time = nil
3737
@minimum_round_trip_time = 0
38+
@lock = Mutex.new
3839
@rtts = []
3940
end
4041

@@ -60,8 +61,10 @@ def measure
6061
# but we must not update the round trip time recorded in the server.
6162
unless exc
6263
@last_round_trip_time = last_rtt
63-
update_average_round_trip_time
64-
update_minimum_round_trip_time
64+
@lock.synchronize do
65+
update_average_round_trip_time
66+
update_minimum_round_trip_time
67+
end
6568
end
6669

6770
if exc

0 commit comments

Comments
 (0)