Browse Source

Fixed CSHARP-225. ReplicaSetConnector.Connect now makes sure that the serverInstance it identifies as primary was connected to using the official replica set configured host name for that server. Also fixed a NullReferenceException in MongoServerInstance.Disconnet.

pull/62/merge
rstam 14 years ago
parent
commit
d66802746a
  1. 7
      Driver/Core/MongoServerInstance.cs
  2. 11
      Driver/Internal/ReplicaSetConnector.cs

7
Driver/Core/MongoServerInstance.cs

@ -239,8 +239,11 @@ namespace MongoDB.Driver {
internal void Disconnect() {
if (state != MongoServerState.Disconnected) {
try {
connectionPool.Close();
connectionPool = null;
// if we fail during Connect the connectionPool field will still be null
if (connectionPool != null) {
connectionPool.Close();
connectionPool = null;
}
} finally {
State = MongoServerState.Disconnected;
}

11
Driver/Internal/ReplicaSetConnector.cs

@ -68,9 +68,14 @@ namespace MongoDB.Driver.Internal {
// return as soon as we've connected to the primary
var serverInstance = response.ServerInstance;
if (serverInstance.State == MongoServerState.Connected && serverInstance.IsPrimary) {
// process any additional responses in the background
ThreadPool.QueueUserWorkItem(ProcessAdditionalResponsesWorkItem);
return;
// make sure this serverInstance is still an instance of this server
// it might have been removed if the connection string used a DNS alias for the host
// (in which case we have already queued a connect using the official host name and should see that response shortly)
if (server.Instances.Contains(serverInstance)) {
// process any additional responses in the background
ThreadPool.QueueUserWorkItem(ProcessAdditionalResponsesWorkItem);
return;
}
}
}

Loading…
Cancel
Save