Skip to content

Commit

Permalink
Add synchronization
Browse files Browse the repository at this point in the history
  • Loading branch information
comandeo-mongo committed Jul 1, 2024
1 parent dbb8ce3 commit 9b54927
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/mongo/server/round_trip_time_calculator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def initialize
@last_round_trip_time = nil
@average_round_trip_time = nil
@minimum_round_trip_time = 0
@lock = Mutex.new
@rtts = []
end

Expand All @@ -60,8 +61,10 @@ def measure
# but we must not update the round trip time recorded in the server.
unless exc
@last_round_trip_time = last_rtt
update_average_round_trip_time
update_minimum_round_trip_time
@lock.synchronized do
update_average_round_trip_time
update_minimum_round_trip_time
end
end

if exc
Expand Down

0 comments on commit 9b54927

Please sign in to comment.