LMDB key value backend for ldb_tdb (to be renamed ldb_key_val)

jim jim.brown at rsmas.miami.edu
Wed Feb 21 23:26:11 UTC 2018


On 2/21/2018 5:45 PM, Garming Sam via samba-technical wrote:
> diff --git a/source4/dsdb/samdb/ldb_modules/partition_metadata.c b/source4/dsdb/samdb/ldb_modules/partition_metadata.c
> index 3c5180b..3ba7905 100644
> --- a/source4/dsdb/samdb/ldb_modules/partition_metadata.c
> +++ b/source4/dsdb/samdb/ldb_modules/partition_metadata.c
> @@ -319,13 +319,33 @@ int partition_metadata_init(struct ldb_module *module)
>   		goto end;
>   	}
>   
> +	ret = partition_start_trans(module);
> +	if (ret != LDB_SUCCESS) {
> +		talloc_free(data->metadata);
> +		data->metadata = NULL;
> +	}
> +
>   	ret = partition_metadata_set_sequence_number(module);
>   	if (ret != LDB_SUCCESS) {
>   		talloc_free(data->metadata);
>   		data->metadata = NULL;
> +		partition_del_trans(module);
> +	} else {
> +
> +		ret = partition_prepare_commit(module);
> +		if (ret != LDB_SUCCESS) {
> +			talloc_free(data->metadata);
> +			data->metadata = NULL;
> +		} else {
> +			ret = partition_end_trans(module);
> +			if (ret != LDB_SUCCESS) {
> +				talloc_free(data->metadata);
> +				data->metadata = NULL;
> +			}
> +		}
>   	}
>   
> -end:
> +	end:
>   	return ret;
>   }
You should 'goto end;' in each failure case just like the original code.
This will eliminate the 'else' groups and all of the extra indentation. 
It will read easier too.

Do you need to call partition_del_trans(module) when 
partition_prepare_commit and partition_prepare_commit fail?




More information about the samba-technical mailing list