[Freeipa-devel] [PATCH 0106] Fix error handling for initial zone refresh in persistent search

Adam Tkac atkac at redhat.com
Thu Dec 13 14:21:22 UTC 2012


On Thu, Nov 22, 2012 at 02:55:51PM +0100, Petr Spacek wrote:
> Hello,
> 
>     Fix error handling for initial zone refresh in persistent search.
> 
>     Old code terminates watcher thread in case of error. Now initial lookup
>     is restarted after reconnect_interval seconds.

Ack

> From 99a820736eab9ad597b193fe504ca965263b6655 Mon Sep 17 00:00:00 2001
> From: Petr Spacek <pspacek at redhat.com>
> Date: Thu, 22 Nov 2012 14:52:08 +0100
> Subject: [PATCH] Fix error handling for initial zone refresh in persistent
>  search.
> 
> Old code terminates watcher thread in case of error. Now initial lookup
> is restarted after reconnect_interval seconds.
> 
> Signed-off-by: Petr Spacek <pspacek at redhat.com>
> ---
>  src/ldap_helper.c | 22 +++++++++++++++++++---
>  1 file changed, 19 insertions(+), 3 deletions(-)
> 
> diff --git a/src/ldap_helper.c b/src/ldap_helper.c
> index 57235de7da158b7a05de9e35fff2cdaaff74276c..28b2eb45c116572d76fefcfb9f5c1fba5411dc12 100644
> --- a/src/ldap_helper.c
> +++ b/src/ldap_helper.c
> @@ -3757,6 +3757,7 @@ ldap_psearch_watcher(isc_threadarg_t arg)
>  
>  restart:
>  	/* Perform initial lookup */
> +	ldap_query_free(ISC_TRUE, &ldap_qresult);
>  	flush_required = ISC_TRUE;
>  	if (inst->psearch) {
>  		log_debug(1, "Sending initial psearch lookup");
> @@ -3794,15 +3795,30 @@ restart:
>  				if (!sane_sleep(inst, inst->reconnect_interval))
>  					goto cleanup;
>  			}
> -			ldap_query_free(ISC_TRUE, &ldap_qresult);
>  			goto restart;
>  		} else if (flush_required == ISC_TRUE) {
> +			isc_boolean_t restart_needed = ISC_FALSE;
>  			/* First LDAP result after (re)start was received successfully:
>  			 * Unload old zones and flush record cache.
>  			 * We want to save cache in case of search timeout during restart.
>  			 */
> -			CHECK(refresh_zones_from_ldap(inst, ISC_TRUE));
> -			CHECK(flush_ldap_cache(inst->cache));
> +			if ((result = refresh_zones_from_ldap(inst, ISC_TRUE))
> +			     != ISC_R_SUCCESS) {
> +				log_error_r("zone refresh after initial psearch lookup failed");
> +				restart_needed = ISC_TRUE;
> +			} else if ((result = flush_ldap_cache(inst->cache))
> +				    != ISC_R_SUCCESS) {
> +				log_error_r("cache flush after initial psearch lookup failed");
> +				restart_needed = ISC_TRUE;
> +			}
> +
> +			if (restart_needed) {
> +				if (!sane_sleep(inst, inst->reconnect_interval))
> +					goto cleanup;
> +
> +				goto restart;
> +			}
> +
>  			flush_required = ISC_FALSE;
>  		}
>  
> -- 
> 1.7.11.7
> 


-- 
Adam Tkac, Red Hat, Inc.




More information about the Freeipa-devel mailing list