@@ -219,15 +219,15 @@ public IPEndPoint GetIPEndPoint()
219
219
/// </summary>
220
220
public void Ping ( )
221
221
{
222
- var connection = _connectionPool . AcquireConnection ( null ) ;
222
+ // use a new connection instead of one from the connection pool
223
+ var connection = new MongoConnection ( this ) ;
223
224
try
224
225
{
225
- var pingCommand = new CommandDocument ( "ping" , 1 ) ;
226
- connection . RunCommand ( "admin.$cmd" , QueryFlags . SlaveOk , pingCommand , true ) ;
226
+ Ping ( connection ) ;
227
227
}
228
228
finally
229
229
{
230
- _connectionPool . ReleaseConnection ( connection ) ;
230
+ connection . Close ( ) ;
231
231
}
232
232
}
233
233
@@ -238,21 +238,22 @@ public void VerifyState()
238
238
{
239
239
lock ( _serverInstanceLock )
240
240
{
241
- // Console.WriteLine("MongoServerInstance[{0}]: VerifyState called.", sequentialId);
242
- // if ping fails assume all connections in the connection pool are doomed
241
+ // use a new connection instead of one from the connection pool
242
+ var connection = new MongoConnection ( this ) ;
243
243
try
244
244
{
245
- Ping ( ) ;
246
- }
247
- catch
248
- {
249
- // Console.WriteLine("MongoServerInstance[{0}]: Ping failed: {1}.", sequentialId, ex.Message);
250
- _connectionPool . Clear ( ) ;
251
- }
245
+ // Console.WriteLine("MongoServerInstance[{0}]: VerifyState called.", sequentialId);
246
+ // if ping fails assume all connections in the connection pool are doomed
247
+ try
248
+ {
249
+ Ping ( connection ) ;
250
+ }
251
+ catch
252
+ {
253
+ // Console.WriteLine("MongoServerInstance[{0}]: Ping failed: {1}.", sequentialId, ex.Message);
254
+ _connectionPool . Clear ( ) ;
255
+ }
252
256
253
- var connection = _connectionPool . AcquireConnection ( null ) ;
254
- try
255
- {
256
257
var previousState = _state ;
257
258
try
258
259
{
@@ -270,7 +271,7 @@ public void VerifyState()
270
271
}
271
272
finally
272
273
{
273
- _connectionPool . ReleaseConnection ( connection ) ;
274
+ connection . Close ( ) ;
274
275
}
275
276
}
276
277
}
@@ -373,6 +374,12 @@ internal void Disconnect()
373
374
}
374
375
}
375
376
377
+ internal void Ping ( MongoConnection connection )
378
+ {
379
+ var pingCommand = new CommandDocument ( "ping" , 1 ) ;
380
+ connection . RunCommand ( "admin.$cmd" , QueryFlags . SlaveOk , pingCommand , true ) ;
381
+ }
382
+
376
383
internal void ReleaseConnection ( MongoConnection connection )
377
384
{
378
385
_connectionPool . ReleaseConnection ( connection ) ;
0 commit comments