dovecot-2.1: lib-dict: Fixed hang if async commit's callback did...

dovecot at dovecot.org dovecot at dovecot.org
Fri Feb 22 13:51:12 EET 2013


details:   http://hg.dovecot.org/dovecot-2.1/rev/225c64ed0439
changeset: 14919:225c64ed0439
user:      Timo Sirainen <tss at iki.fi>
date:      Fri Feb 22 13:51:02 2013 +0200
description:
lib-dict: Fixed hang if async commit's callback did more dict access.
Specifically this fixes a hang with dict-quota plugin when user didn't exist
and quota was changed before calculating it.

diffstat:

 src/lib-dict/dict-client.c |  12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

diffs (26 lines):

diff -r 81ea622b6394 -r 225c64ed0439 src/lib-dict/dict-client.c
--- a/src/lib-dict/dict-client.c	Fri Feb 22 12:19:36 2013 +0200
+++ b/src/lib-dict/dict-client.c	Fri Feb 22 13:51:02 2013 +0200
@@ -262,15 +262,17 @@
 		i_error("dict-client: Unknown transaction id %u", id);
 		return;
 	}
-	if (ctx->callback != NULL)
-		ctx->callback(ret, ctx->context);
 
-	DLLIST_REMOVE(&dict->transactions, ctx);
-	i_free(ctx);
-
+	/* the callback may call the dict code again, so remove this
+	   transaction before calling it */
 	i_assert(dict->async_commits > 0);
 	if (--dict->async_commits == 0)
 		io_remove(&dict->io);
+	DLLIST_REMOVE(&dict->transactions, ctx);
+
+	if (ctx->callback != NULL)
+		ctx->callback(ret, ctx->context);
+	i_free(ctx);
 }
 
 static ssize_t client_dict_read_timeout(struct client_dict *dict)


More information about the dovecot-cvs mailing list