// Token: 0x06000DC3 RID: 3523 RVA: 0x0003F004 File Offset: 0x0003D204
 internal void MoveConnectionAcrossPool(LdapConnectionPool sourcePool, List <PooledLdapConnection> connectionsToRelease)
 {
     try
     {
         sourcePool.poolLock.AcquireWriterLock(-1);
         this.poolLock.AcquireReaderLock(-1);
         if (!sourcePool.isActive)
         {
             ExTraceGlobals.GetConnectionTracer.TraceWarning((long)sourcePool.GetHashCode(), "Source Pool is not active, skipping MoveConnectionAcrossPool");
         }
         else if (this.connectionInfos == null || this.connectionInfos.Length <= 0)
         {
             ExTraceGlobals.GetConnectionTracer.TraceWarning((long)this.GetHashCode(), "Target Pool does not have active connections, skipping MoveConnectionAcrossPool");
         }
         else
         {
             for (int i = 0; i < sourcePool.connectionInfos.Length; i++)
             {
                 ConnectionInfo connectionInfo = sourcePool.connectionInfos[i];
                 if (connectionInfo.ConnectionState == ConnectionState.Connected && connectionInfo.PooledLdapConnection != null && connectionInfo.PooledLdapConnection.IsUp)
                 {
                     for (int j = 0; j < this.connectionInfos.Length; j++)
                     {
                         ConnectionInfo connectionInfo2 = this.connectionInfos[j];
                         if (connectionInfo2.ConnectionState == ConnectionState.Empty && connectionInfo.ADServerInfo.Equals(connectionInfo2.ADServerInfo))
                         {
                             this.ExecuteConnectionMove(connectionInfo2, connectionInfo, sourcePool);
                             this.DisconnectSourceAfterConnectionMove(connectionInfo, sourcePool, connectionsToRelease);
                             break;
                         }
                     }
                 }
             }
         }
     }
     finally
     {
         try
         {
             this.poolLock.ReleaseReaderLock();
         }
         catch (ApplicationException)
         {
         }
         try
         {
             sourcePool.poolLock.ReleaseWriterLock();
         }
         catch (ApplicationException)
         {
         }
     }
 }
 // Token: 0x06000DC4 RID: 3524 RVA: 0x0003F150 File Offset: 0x0003D350
 private void ExecuteConnectionMove(ConnectionInfo targetInfo, ConnectionInfo sourceInfo, LdapConnectionPool sourcePool)
 {
     ExTraceGlobals.GetConnectionTracer.TraceDebug <string, string, int>((long)this.GetHashCode(), "Moving connection to {0}={1} from pool {2}", sourceInfo.ADServerInfo.FqdnPlusPort, targetInfo.ADServerInfo.FqdnPlusPort, sourcePool.GetHashCode());
     targetInfo.TryMakeConnecting();
     targetInfo.PooledLdapConnection = sourceInfo.PooledLdapConnection;
     targetInfo.PooledLdapConnection.BorrowFromPool();
     targetInfo.MakeConnected();
     Interlocked.Increment(ref this.connectedCount);
     ExTraceGlobals.GetConnectionTracer.TraceDebug <string>((long)this.GetHashCode(), "Moved connection to {0} to the new pool", sourceInfo.ADServerInfo.FqdnPlusPort);
 }
        // Token: 0x06000DC2 RID: 3522 RVA: 0x0003EE0C File Offset: 0x0003D00C
        private void MoveOrDisconnect(int[] serverMapping, LdapConnectionPool sourcePool, List <PooledLdapConnection> connectionsToRelease)
        {
            bool flag = sourcePool == this;

            try
            {
                sourcePool.poolLock.AcquireWriterLock(-1);
                this.poolLock.AcquireReaderLock(-1);
                if (!sourcePool.isActive)
                {
                    ExTraceGlobals.GetConnectionTracer.TraceWarning((long)sourcePool.GetHashCode(), "Source Pool is not active, skipping MoveConnectionsAndDisconnect");
                }
                else
                {
                    for (int i = 0; i < sourcePool.connectionInfos.Length; i++)
                    {
                        ConnectionInfo connectionInfo = sourcePool.connectionInfos[i];
                        if (!flag)
                        {
                            int num = -1;
                            for (int j = 0; j < serverMapping.Length; j++)
                            {
                                if (serverMapping[j] == i)
                                {
                                    num = j;
                                    break;
                                }
                            }
                            if (num != -1 && this.connectionInfos != null && this.connectionInfos.Length > 0)
                            {
                                ConnectionInfo connectionInfo2 = this.connectionInfos[num];
                                if (connectionInfo.ConnectionState == ConnectionState.Connected && connectionInfo.PooledLdapConnection.IsUp && connectionInfo2.ConnectionState == ConnectionState.Empty)
                                {
                                    this.ExecuteConnectionMove(connectionInfo2, connectionInfo, sourcePool);
                                }
                                else
                                {
                                    ExTraceGlobals.GetConnectionTracer.TraceWarning <string, int, string>((long)this.GetHashCode(), "Not moving connection to {0} because its state is {1} and IsUp={2}", connectionInfo.ADServerInfo.FqdnPlusPort, (int)connectionInfo.ConnectionState, (connectionInfo.PooledLdapConnection == null) ? "<n/a>" : connectionInfo.PooledLdapConnection.IsUp.ToString());
                                }
                            }
                        }
                        if (connectionInfo.ConnectionState == ConnectionState.Connected)
                        {
                            this.DisconnectSourceAfterConnectionMove(connectionInfo, sourcePool, connectionsToRelease);
                        }
                        else
                        {
                            ExTraceGlobals.GetConnectionTracer.TraceWarning <string, int>((long)this.GetHashCode(), "Not Disconnecting connection to {0} because its state is {1}", connectionInfo.ADServerInfo.FqdnPlusPort, (int)connectionInfo.ConnectionState);
                        }
                    }
                    ExTraceGlobals.GetConnectionTracer.TraceDebug((long)sourcePool.GetHashCode(), "Deactivating Source Pool");
                    sourcePool.isActive = false;
                }
            }
            finally
            {
                try
                {
                    this.poolLock.ReleaseReaderLock();
                }
                catch (ApplicationException)
                {
                }
                try
                {
                    sourcePool.poolLock.ReleaseWriterLock();
                }
                catch (ApplicationException)
                {
                }
            }
        }