This is an automated email from the ASF dual-hosted git repository.

sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/whimsy.git


The following commit(s) were added to refs/heads/master by this push:
     new bd0928b  HOST_QUEUE does not play well when a host list is provided
bd0928b is described below

commit bd0928bb7a1aad08e9829465726f80a48c1edaa3
Author: Sebb <[email protected]>
AuthorDate: Sun Jan 12 14:58:32 2020 +0000

    HOST_QUEUE does not play well when a host list is provided
---
 lib/whimsy/asf/ldap.rb | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/lib/whimsy/asf/ldap.rb b/lib/whimsy/asf/ldap.rb
index f72b20c..49f0dbe 100644
--- a/lib/whimsy/asf/ldap.rb
+++ b/lib/whimsy/asf/ldap.rb
@@ -60,9 +60,6 @@ module ASF
     # Mutex preventing simultaneous connections to LDAP from a single process
     CONNECT_LOCK = Mutex.new
 
-    # Round robin list of LDAP hosts to be tried after failure
-    HOST_QUEUE = Queue.new
-
     # fetch configuration from apache/infrastructure-puppet
     def self.puppet_config
       return @puppet if @puppet
@@ -79,13 +76,12 @@ module ASF
 
     # connect to LDAP
     def self.connect(test = true, hosts = nil)
-      hosts ||= self.hosts
+      # If the host list is specified, use that as is
+      # otherwise ensure we start with the next in the default list
+      hosts ||= self.hosts.rotate!
 
       # Try each host at most once
-      hosts.length.times do
-        # Ensure we use each host in turn
-        hosts.each {|host| HOST_QUEUE.push host} if HOST_QUEUE.empty?
-        host = HOST_QUEUE.shift
+      hosts.each do |host|
 
         Wunderbar.info "[#{host}] - Connecting to LDAP server"
 

Reply via email to