Commit 1f1780579007f1f1c4868f4e38b8b22a1c8ab458:
    Cycle hosts, but only try each once per connect attempt


Branch: refs/heads/master
Author: Sebb <[email protected]>
Committer: Sebb <[email protected]>
Pusher: sebb <[email protected]>

------------------------------------------------------------
lib/whimsy/asf/ldap.rb                                       | +++++ ---
------------------------------------------------------------
8 changes: 5 additions, 3 deletions.
------------------------------------------------------------


diff --git a/lib/whimsy/asf/ldap.rb b/lib/whimsy/asf/ldap.rb
index 0376c64..d326cf2 100644
--- a/lib/whimsy/asf/ldap.rb
+++ b/lib/whimsy/asf/ldap.rb
@@ -73,7 +73,8 @@ def self.puppet_ldapservers
 
     # connect to LDAP
     def self.connect
-      loop do
+      # Try each host at most once
+      hosts.length.times do
         host = next_host
         Wunderbar.info "Connecting to LDAP server: #{host}"
 
@@ -99,6 +100,7 @@ def self.connect
         end
 
       end
+
       Wunderbar.error "Failed to connect to any LDAP host"
       return nil
     end
@@ -569,9 +571,9 @@ def self.hosts
       @hosts = hosts
     end
 
-    # Ensure we only use each host once
+    # Ensure we use each host in turn
     def self.next_host
-       @he ||= hosts.to_enum 
+       @he ||= hosts.cycle 
        @he.next
     end
 

Reply via email to