dovecot-2.1: lib-dict: Error handling fixes to asynchronous tran...

dovecot at dovecot.org dovecot at dovecot.org
Mon Aug 5 20:53:05 EEST 2013


details:   http://hg.dovecot.org/dovecot-2.1/rev/c7832e75d2a8
changeset: 14993:c7832e75d2a8
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Jun 12 22:03:07 2013 +0300
description:
lib-dict: Error handling fixes to asynchronous transactions.

diffstat:

 src/lib-dict/dict-client.c |  10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diffs (55 lines):

diff -r 589d2f485a6e -r c7832e75d2a8 src/lib-dict/dict-client.c
--- a/src/lib-dict/dict-client.c	Mon Aug 05 17:38:13 2013 +0300
+++ b/src/lib-dict/dict-client.c	Wed Jun 12 22:03:07 2013 +0300
@@ -73,6 +73,7 @@
 	unsigned int failed:1;
 	unsigned int sent_begin:1;
 	unsigned int async:1;
+	unsigned int committed:1;
 };
 
 static int client_dict_connect(struct client_dict *dict);
@@ -262,6 +263,9 @@
 		i_error("dict-client: Unknown transaction id %u", id);
 		return;
 	}
+	ctx->failed = TRUE;
+	if (!ctx->committed)
+		return;
 
 	/* the callback may call the dict code again, so remove this
 	   transaction before calling it */
@@ -402,8 +406,6 @@
 {
 	const char *query;
 
-	i_assert(dict->fd == -1);
-
 	if (dict->last_failed_connect == ioloop_time) {
 		/* Try again later */
 		return -1;
@@ -427,8 +429,6 @@
 
 	dict->input = i_stream_create_fd(dict->fd, (size_t)-1, FALSE);
 	dict->output = o_stream_create_fd(dict->fd, 4096, FALSE);
-	dict->transaction_id_counter = 0;
-	dict->async_commits = 0;
 
 	query = t_strdup_printf("%c%u\t%u\t%d\t%s\t%s\n",
 				DICT_PROTOCOL_CMD_HELLO,
@@ -516,6 +516,7 @@
 	struct client_dict *dict = (struct client_dict *)_dict;
 
         client_dict_disconnect(dict);
+	i_assert(dict->transactions == NULL);
 	pool_unref(&dict->pool);
 }
 
@@ -706,6 +707,7 @@
 	struct client_dict *dict = (struct client_dict *)_ctx->dict;
 	int ret = ctx->failed ? -1 : 1;
 
+	ctx->committed = TRUE;
 	if (ctx->sent_begin && !ctx->failed) T_BEGIN {
 		const char *query, *line;
 


More information about the dovecot-cvs mailing list