]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-dict: Fixed hang if async commit's callback did more dict access.
authorTimo Sirainen <tss@iki.fi>
Fri, 22 Feb 2013 11:51:02 +0000 (13:51 +0200)
committerTimo Sirainen <tss@iki.fi>
Fri, 22 Feb 2013 11:51:02 +0000 (13:51 +0200)
Specifically this fixes a hang with dict-quota plugin when user didn't exist
and quota was changed before calculating it.

src/lib-dict/dict-client.c

index 1f97c55f26bbdf09378a7d63309c72866c9009d9..813cb6162a8815ed4ba8cd257ad7579cae4d72d7 100644 (file)
@@ -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)