dovecot-2.2: dict-sql: Code cleanup - added sql_dict_transaction...

dovecot at dovecot.org dovecot at dovecot.org
Wed Sep 2 14:29:46 UTC 2015


details:   http://hg.dovecot.org/dovecot-2.2/rev/dd083fddda5e
changeset: 19063:dd083fddda5e
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Sep 02 17:28:41 2015 +0300
description:
dict-sql: Code cleanup - added sql_dict_transaction_has_nonexistent()

diffstat:

 src/lib-dict/dict-sql.c |  23 +++++++++++++++--------
 1 files changed, 15 insertions(+), 8 deletions(-)

diffs (40 lines):

diff -r cb6d6d861ffa -r dd083fddda5e src/lib-dict/dict-sql.c
--- a/src/lib-dict/dict-sql.c	Wed Sep 02 17:27:09 2015 +0300
+++ b/src/lib-dict/dict-sql.c	Wed Sep 02 17:28:41 2015 +0300
@@ -537,6 +537,19 @@
 	i_free(ctx);
 }
 
+static bool
+sql_dict_transaction_has_nonexistent(struct sql_dict_transaction_context *ctx)
+{
+	struct sql_dict_inc_row *inc_row;
+
+	for (inc_row = ctx->inc_row; inc_row != NULL; inc_row = inc_row->prev) {
+		i_assert(inc_row->rows != UINT_MAX);
+		if (inc_row->rows == 0)
+			return TRUE;
+	}
+	return FALSE;
+}
+
 static int
 sql_dict_transaction_commit(struct dict_transaction_context *_ctx,
 			    bool async ATTR_UNUSED,
@@ -562,14 +575,8 @@
 			i_error("sql dict: commit failed: %s", error);
 			ret = -1;
 		} else {
-			while (ctx->inc_row != NULL) {
-				i_assert(ctx->inc_row->rows != UINT_MAX);
-				if (ctx->inc_row->rows == 0) {
-					ret = 0;
-					break;
-				}
-				ctx->inc_row = ctx->inc_row->prev;
-			}
+			if (sql_dict_transaction_has_nonexistent(ctx))
+				ret = 0;
 		}
 	}
 	sql_dict_transaction_free(ctx);


More information about the dovecot-cvs mailing list