@@ -54,7 +54,6 @@ public sealed class MongoServerInstance
54
54
private Exception _connectException ;
55
55
private bool _inStateVerification ;
56
56
private ServerInformation _serverInfo ;
57
- private IPEndPoint _ipEndPoint ;
58
57
private bool _permanentlyDisconnected ;
59
58
private int _sequentialId ;
60
59
private MongoServerState _state ;
@@ -340,7 +339,7 @@ public MongoServerState State
340
339
internal bool IsCompatible
341
340
{
342
341
get
343
- {
342
+ {
344
343
Range < int > serverRange ;
345
344
lock ( _serverInstanceLock )
346
345
{
@@ -358,16 +357,8 @@ internal bool IsCompatible
358
357
/// <returns>The IP end point of this server instance.</returns>
359
358
public IPEndPoint GetIPEndPoint ( )
360
359
{
361
- // use a lock free algorithm because DNS lookups are rare and concurrent lookups are tolerable
362
- // the intermediate variable is important to avoid race conditions
363
- var ipEndPoint = Interlocked . CompareExchange ( ref _ipEndPoint , null , null ) ;
364
- if ( ipEndPoint == null )
365
- {
366
- var addressFamily = _settings . IPv6 ? AddressFamily . InterNetworkV6 : AddressFamily . InterNetwork ;
367
- ipEndPoint = _address . ToIPEndPoint ( addressFamily ) ;
368
- Interlocked . CompareExchange ( ref _ipEndPoint , _ipEndPoint , null ) ;
369
- }
370
- return ipEndPoint ;
360
+ var addressFamily = _settings . IPv6 ? AddressFamily . InterNetworkV6 : AddressFamily . InterNetwork ;
361
+ return _address . ToIPEndPoint ( addressFamily ) ;
371
362
}
372
363
373
364
/// <summary>
@@ -540,7 +531,7 @@ internal void Disconnect()
540
531
}
541
532
542
533
// we know for certain state has just changed.
543
- OnStateChanged ( ) ;
534
+ OnStateChanged ( ) ;
544
535
545
536
try
546
537
{
0 commit comments