From c720e349a453f28cec6389bda07f306cef22f0c8 Mon Sep 17 00:00:00 2001 From: Marc Fournier Date: Wed, 14 Oct 2015 17:44:04 +0200 Subject: [PATCH] openldap: make connection to server persistent Removes the overhead of connection setup/teardown at each read interval. --- src/openldap.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/openldap.c b/src/openldap.c index ffcdb94e..1ef9f7b9 100644 --- a/src/openldap.c +++ b/src/openldap.c @@ -74,6 +74,13 @@ static int cldap_init_host (cldap_t *st) /* {{{ */ { LDAP *ld; int rc; + + if (st->state && st->ld) + { + DEBUG ("openldap plugin: Already connected to %s", st->url); + return (0); + } + rc = ldap_initialize (&ld, st->url); if (rc != LDAP_SUCCESS) { @@ -231,6 +238,7 @@ static int cldap_read_host (user_data_t *ud) /* {{{ */ ERROR ("openldap plugin: Failed to execute search: %s", ldap_err2string (rc)); ldap_msgfree (result); + st->state = 0; ldap_unbind_ext_s (st->ld, NULL, NULL); return (-1); } @@ -528,7 +536,6 @@ static int cldap_read_host (user_data_t *ud) /* {{{ */ } ldap_msgfree (result); - ldap_unbind_ext_s (st->ld, NULL, NULL); return (0); } /* }}} int cldap_read_host */ -- 2.30.2