From 3c585e9a8068d5065b1a5f320ffd130290c1cd07 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 28 Apr 2010 10:39:05 +1000 Subject: s4:provisionbackend Don't loop forever waiting for OpenLDAP We need to give a good error when we can't get OpenLDAP to accept our connections. Andrew Bartlett --- source4/scripting/python/samba/provisionbackend.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/source4/scripting/python/samba/provisionbackend.py b/source4/scripting/python/samba/provisionbackend.py index 25e416ce04..8d035ab670 100644 --- a/source4/scripting/python/samba/provisionbackend.py +++ b/source4/scripting/python/samba/provisionbackend.py @@ -222,6 +222,7 @@ class LDAPBackend(ProvisionBackend): self.slapd = subprocess.Popen(self.slapd_provision_command, close_fds=True, shell=False) + count = 0 while self.slapd.poll() is None: # Wait until the socket appears try: @@ -232,6 +233,11 @@ class LDAPBackend(ProvisionBackend): return except LdbError: time.sleep(1) + count = count + 1 + + if count > 15: + self.message("Could not connect to slapd started with: %s" % "\'" + "\' \'".join(self.slapd_provision_command) + "\'") + raise ProvisioningError("slapd never accepted a connection within 15 seconds of starting") self.message("Could not start slapd with: %s" % "\'" + "\' \'".join(self.slapd_provision_command) + "\'") raise ProvisioningError("slapd died before we could make a connection to it") -- cgit