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 @@ -56,7 +56,6 @@ type rttMonitor struct {
56
56
cfg * rttConfig
57
57
ctx context.Context
58
58
cancelFn context.CancelFunc
59
- started bool
60
59
}
61
60
62
61
var _ driver.RTTMonitor = & rttMonitor {}
@@ -83,7 +82,6 @@ func (r *rttMonitor) connect() {
83
82
r .connMu .Lock ()
84
83
defer r .connMu .Unlock ()
85
84
86
- r .started = true
87
85
r .closeWg .Add (1 )
88
86
89
87
go func () {
@@ -97,10 +95,6 @@ func (r *rttMonitor) disconnect() {
97
95
r .connMu .Lock ()
98
96
defer r .connMu .Unlock ()
99
97
100
- if ! r .started {
101
- return
102
- }
103
-
104
98
r .cancelFn ()
105
99
106
100
// 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
@@ -661,8 +662,8 @@ func (s *Server) update() {
661
662
transitionedFromNetworkError := desc .LastError != nil && unwrapConnectionError (desc .LastError ) != nil &&
662
663
previousDescription .Kind != description .Unknown
663
664
664
- if isStreamingEnabled (s ) && isStreamable (s ) && ! s . rttMonitor . started {
665
- s .rttMonitor .connect ( )
665
+ if isStreamingEnabled (s ) && isStreamable (s ) {
666
+ s .monitorOnce . Do ( s . rttMonitor .connect )
666
667
}
667
668
668
669
if isStreamable (s ) || connectionIsStreaming || transitionedFromNetworkError {
You can’t perform that action at this time.
0 commit comments