changeset 21799:0bb58080e0a6

lib-dict: Use dict-fail iterator and transaction when missing from dict driver
author Aki Tuomi <aki.tuomi@dovecot.fi>
date Wed, 22 Mar 2017 10:32:58 +0200
parents 7d4264ff0d9a
children a1ebd140977c
files src/lib-dict/dict.c
diffstat 1 files changed, 3 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-dict/dict.c	Wed Mar 22 12:05:32 2017 +0200
+++ b/src/lib-dict/dict.c	Wed Mar 22 10:32:58 2017 +0200
@@ -7,7 +7,6 @@
 #include "dict-private.h"
 
 static ARRAY(struct dict *) dict_drivers;
-static struct dict_iterate_context dict_iter_unsupported;
 
 static struct dict *dict_driver_lookup(const char *name)
 {
@@ -187,8 +186,6 @@
 bool dict_iterate(struct dict_iterate_context *ctx,
 		  const char **key_r, const char **value_r)
 {
-	if (ctx == &dict_iter_unsupported)
-		return FALSE;
 	if (ctx->max_rows > 0 && ctx->row_count >= ctx->max_rows) {
 		/* row count was limited */
 		ctx->has_more = FALSE;
@@ -227,12 +224,13 @@
 	ctx->dict->iter_count--;
 
 	*_ctx = NULL;
-	return ctx == &dict_iter_unsupported ? -1 :
-		ctx->dict->v.iterate_deinit(ctx);
+	return ctx->dict->v.iterate_deinit(ctx);
 }
 
 struct dict_transaction_context *dict_transaction_begin(struct dict *dict)
 {
+	if (dict->v.transaction_init == NULL)
+		return &dict_transaction_unsupported;
 	return dict->v.transaction_init(dict);
 }