File tree 2 files changed +4
-9
lines changed
2 files changed +4
-9
lines changed Original file line number Diff line number Diff line change @@ -54,7 +54,6 @@ type rttMonitor struct {
54
54
cfg * rttConfig
55
55
ctx context.Context
56
56
cancelFn context.CancelFunc
57
- started bool
58
57
}
59
58
60
59
var _ driver.RTTMonitor = & rttMonitor {}
@@ -78,7 +77,6 @@ func (r *rttMonitor) connect() {
78
77
r .connMu .Lock ()
79
78
defer r .connMu .Unlock ()
80
79
81
- r .started = true
82
80
r .closeWg .Add (1 )
83
81
84
82
go func () {
@@ -92,10 +90,6 @@ func (r *rttMonitor) disconnect() {
92
90
r .connMu .Lock ()
93
91
defer r .connMu .Unlock ()
94
92
95
- if ! r .started {
96
- return
97
- }
98
-
99
93
r .cancelFn ()
100
94
101
95
// Wait for the existing connection to complete.
Original file line number Diff line number Diff line change @@ -125,6 +125,7 @@ type Server struct {
125
125
126
126
processErrorLock sync.Mutex
127
127
rttMonitor * rttMonitor
128
+ monitorOnce sync.Once
128
129
}
129
130
130
131
// updateTopologyCallback is a callback used to create a server that should be called when the parent Topology instance
@@ -285,10 +286,10 @@ func (s *Server) Disconnect(ctx context.Context) error {
285
286
close (s .done )
286
287
s .cancelCheck ()
287
288
288
- s .rttMonitor .disconnect ()
289
289
s .pool .close (ctx )
290
290
291
291
s .closewg .Wait ()
292
+ s .rttMonitor .disconnect ()
292
293
atomic .StoreInt64 (& s .state , serverDisconnected )
293
294
294
295
return nil
@@ -666,8 +667,8 @@ func (s *Server) update() {
666
667
transitionedFromNetworkError := desc .LastError != nil && unwrapConnectionError (desc .LastError ) != nil &&
667
668
previousDescription .Kind != description .Unknown
668
669
669
- if isStreamingEnabled (s ) && isStreamable (s ) && ! s . rttMonitor . started {
670
- s .rttMonitor .connect ( )
670
+ if isStreamingEnabled (s ) && isStreamable (s ) {
671
+ s .monitorOnce . Do ( s . rttMonitor .connect )
671
672
}
672
673
673
674
if isStreamable (s ) && (serverSupportsStreaming || connectionIsStreaming ) || transitionedFromNetworkError {
You can’t perform that action at this time.
0 commit comments