-
Notifications
You must be signed in to change notification settings - Fork 891
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GODRIVER-3107 Fix leaking rttMonitor.runHellos() routine. #1587
Conversation
API Change ReportNo changes found! |
s.pool.close(ctx) | ||
|
||
s.closewg.Wait() | ||
s.rttMonitor.disconnect() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does not cause any actual impact whether or not this line is moved. I put it here as a "fail-safe" that disconnects after the update()
exits, so rttMonitor.connect()
is more likely to be called beforehand.
x/mongo/driver/topology/server.go
Outdated
@@ -125,6 +125,7 @@ type Server struct { | |||
|
|||
processErrorLock sync.Mutex | |||
rttMonitor *rttMonitor | |||
monitorOnce *sync.Once |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since Server
is always passed as a pointer, this sync.Once
can be a non-pointer type (like sync.Mutex
above). If it is ever copied, the go vet
linter will cause an error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! 👍
(cherry picked from commit 9648fe1)
GODRIVER-3107
Summary
Fix the leaky
rttMonitor.runHellos()
routine when a disconnect occurs before a connection takes place.Background & Motivation
There is a chance that
rttMonitor.disconnect()
is called beforerttMonitor.connect()
as described in PR #1376. In that case, the condition indisconnect()
triggers a shortcut return which makes therunHellos()
routine impossible to be closed.