@@ -66,7 +66,7 @@ protected Cluster(ClusterSettings settings, IClusterableServerFactory serverFact
66
66
_description = ClusterDescription . CreateInitial ( _clusterId , _settings . ConnectionMode . ToClusterType ( ) ) ;
67
67
_descriptionChangedTaskCompletionSource = new TaskCompletionSource < bool > ( ) ;
68
68
69
- _rapidHeartbeatTimer = new Timer ( o => RequestHeartbeat ( ) , null , Timeout . InfiniteTimeSpan , Timeout . InfiniteTimeSpan ) ;
69
+ _rapidHeartbeatTimer = new Timer ( RapidHeartbeatTimerCallback , null , Timeout . InfiniteTimeSpan , Timeout . InfiniteTimeSpan ) ;
70
70
}
71
71
72
72
// events
@@ -159,6 +159,20 @@ public virtual void Initialize()
159
159
_state . TryChange ( State . Initial , State . Open ) ;
160
160
}
161
161
162
+ private void RapidHeartbeatTimerCallback ( object args )
163
+ {
164
+ try
165
+ {
166
+ RequestHeartbeat ( ) ;
167
+ }
168
+ catch
169
+ {
170
+ // TODO: Trace this
171
+ // If we don't protect this call, we could
172
+ // take down the app domain.
173
+ }
174
+ }
175
+
162
176
protected abstract void RequestHeartbeat ( ) ;
163
177
164
178
protected void OnDescriptionChanged ( ClusterDescription oldDescription , ClusterDescription newDescription )
@@ -188,14 +202,14 @@ public async Task<IServer> SelectServerAsync(IServerSelector selector, Cancellat
188
202
if ( _settings . PreServerSelector != null || _settings . PostServerSelector != null )
189
203
{
190
204
var allSelectors = new List < IServerSelector > ( ) ;
191
- if ( _settings . PreServerSelector != null )
205
+ if ( _settings . PreServerSelector != null )
192
206
{
193
207
allSelectors . Add ( _settings . PreServerSelector ) ;
194
208
}
195
209
196
210
allSelectors . Add ( selector ) ;
197
211
198
- if ( _settings . PostServerSelector != null )
212
+ if ( _settings . PostServerSelector != null )
199
213
{
200
214
allSelectors . Add ( _settings . PostServerSelector ) ;
201
215
}
0 commit comments