From: Timo Sirainen Date: Fri, 22 Feb 2013 11:51:02 +0000 (+0200) Subject: lib-dict: Fixed hang if async commit's callback did more dict access. X-Git-Tag: 2.2.rc1~1^2~6 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=79b0f6ec3e5fde8f878bd85f4a1c3d669af66ebe;p=thirdparty%2Fdovecot%2Fcore.git 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. --- diff --git a/src/lib-dict/dict-client.c b/src/lib-dict/dict-client.c index 1f97c55f26..813cb6162a 100644 --- a/src/lib-dict/dict-client.c +++ b/src/lib-dict/dict-client.c @@ -262,15 +262,17 @@ client_dict_finish_transaction(struct client_dict *dict, 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)