From 0257e00561658908365a58da5acd8051f057b747 Mon Sep 17 00:00:00 2001 From: Martin Nagy Date: Fri, 4 Sep 2009 14:06:24 +0200 Subject: Fix the reconnection code We only did a new ldap bind with the old ldap handle, which didn't work. We fix this by getting rid of the old handle and do a brand new init and bind. Resolves ticket #20 --- src/ldap_helper.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/ldap_helper.c b/src/ldap_helper.c index 8db8851..112c763 100644 --- a/src/ldap_helper.c +++ b/src/ldap_helper.c @@ -1523,10 +1523,11 @@ ldap_connect(ldap_connection_t *ldap_conn) LDAP_OPT_CHECK(ret, "failed to set timeout: %s", ldap_err2string(ret)); */ + if (ldap_conn->handle != NULL) + ldap_unbind_ext_s(ldap_conn->handle, NULL, NULL); ldap_conn->handle = ld; - ldap_reconnect(ldap_conn); - return ISC_R_SUCCESS; + return ldap_reconnect(ldap_conn); cleanup: @@ -1646,11 +1647,10 @@ handle_connection_error(ldap_connection_t *ldap_conn, isc_result_t *result) *result = ISC_R_SUCCESS; ldap_conn->tries = 0; return 0; - } else if (err_code == LDAP_SERVER_DOWN) { + } else if (err_code == LDAP_SERVER_DOWN || LDAP_CONNECT_ERROR) { if (ldap_conn->tries == 0) log_error("connection to the LDAP server was lost"); - *result = ldap_reconnect(ldap_conn); - if (*result == ISC_R_SUCCESS) + if (ldap_connect(ldap_conn) == ISC_R_SUCCESS) return 1; } else { err_string = ldap_err2string(err_code); -- cgit