You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@whimsical.apache.org by Sebastian Bazley <se...@apache.org> on 2016/02/05 23:47:41 UTC
[whimsy.git] [1/1] Commit 921d2a3: Target is not known until after the connect attempt
Commit 921d2a32f35558b02f2bcdd56889cf45356e7d1e:
Target is not known until after the connect attempt
Use .max to get a minimum
Branch: refs/heads/master
Author: Sebb <se...@apache.org>
Committer: Sebb <se...@apache.org>
Pusher: sebb <se...@apache.org>
------------------------------------------------------------
lib/whimsy/asf/ldap.rb | ++++ ----
------------------------------------------------------------
8 changes: 4 additions, 4 deletions.
------------------------------------------------------------
diff --git a/lib/whimsy/asf/ldap.rb b/lib/whimsy/asf/ldap.rb
index 86fb29e..c54fda1 100644
--- a/lib/whimsy/asf/ldap.rb
+++ b/lib/whimsy/asf/ldap.rb
@@ -124,19 +124,19 @@ def self.ldap
# search with a scope of one, with automatic retry/failover
def self.search_one(base, filter, attrs=nil)
- target = @ldap.get_option(::LDAP::LDAP_OPT_HOST_NAME) rescue '?'
cmd = "ldapsearch -x -LLL -b #{base} -s one #{filter} " +
"#{[attrs].flatten.join(' ')}"
- Wunderbar.info "[#{target}] #{cmd}"
-
# try once per host, with a minimum of two tries
- attempts_left = [ASF::LDAP.hosts.length, 2].min
+ attempts_left = [ASF::LDAP.hosts.length, 2].max
begin
attempts_left -= 1
init_ldap unless @ldap
return [] unless @ldap
+ target = @ldap.get_option(::LDAP::LDAP_OPT_HOST_NAME) rescue '?'
+ Wunderbar.info "[#{target}] #{cmd}"
+
result = @ldap.search2(base, ::LDAP::LDAP_SCOPE_ONELEVEL, filter, attrs)
rescue Exception => re
if attempts_left <= 0