[sheepdog] [PATCH v6 6/6] zookeeper: handle session timeout for all zookeeper operations

Liu Yuan namei.unix at gmail.com
Sat Jun 22 11:03:46 CEST 2013


On 06/21/2013 08:34 PM, Kai Zhang wrote:
> +	if (zk_queue_peek(&peek) == ZOK) {
> +		if (!peek)
> +			goto kick_block_event;
> +	} else {
> +		sd_eprintf("failed");
> +		return;
> +	}
>  
> -	zk_queue_pop_advance(&ev);
> +	if (zk_queue_pop_advance(&ev) != ZOK) {
> +		sd_eprintf("failed");
> +		return;
> +	}
>  	if (ev.type < zk_max_event_handlers && zk_event_handlers[ev.type])
>  		zk_event_handlers[ev.type](&ev);
>  	else
>  		panic("unhandled type %d", ev.type);
>  
> -	 /* Someone has created next event, go kick event handler. */
> -	if (zk_queue_peek()) {
> -		eventfd_write(efd, 1);
> +	if (zk_queue_peek(&peek) == ZOK) {
> +		if (peek) {
> +			/*
> +			 * Someone has created next event,
> +			 * go kick event handler.
> +			 */
> +			eventfd_write(efd, 1);
> +			return;
> +		}
> +	} else {
> +		sd_eprintf("failed");
>  		return;
>  	}

This zk_queue_peek() handling looks convoluted. I'd suggest
 - zk_queue_peek() return simply rc as
   return zk_node_exists(path);
 - switch-case handling of rc

Thanks,
Yuan



More information about the sheepdog mailing list