/// <summary> /// Put a pooled connector into the pool queue. /// </summary> /// <param name="Connector">Connector to pool</param> private void UngetPooledConnector(NpgsqlConnection Connection, NpgsqlConnector Connector) { ConnectorQueue Queue; // Find the queue. Queue = (ConnectorQueue)PooledConnectors[Connector.ConnectionString.ToString()]; if (Queue == null) { throw new InvalidOperationException("Internal: No connector queue found for existing connector."); } Connector.CertificateSelectionCallback -= Connection.CertificateSelectionCallbackDelegate; Connector.CertificateValidationCallback -= Connection.CertificateValidationCallbackDelegate; Connector.PrivateKeySelectionCallback -= Connection.PrivateKeySelectionCallbackDelegate; Queue.UseCount--; if (! Connector.IsInitialized) { if (Connector.Transaction != null) { Connector.Transaction.Cancel(); } Connector.Close(); } else { if (Connector.Transaction != null) { try { Connector.Transaction.Rollback(); } catch { Connector.Close() ; } } } if (Connector.State == System.Data.ConnectionState.Open) { // Release all plans and portals associated with this connector. Connector.ReleasePlansPortals(); Queue.Enqueue(Connector); } }