From 511fba2e5821c67be525403598ad18c61f33a2a1 Mon Sep 17 00:00:00 2001 From: Aki Tuomi Date: Fri, 19 Jan 2018 10:27:09 +0200 Subject: [PATCH] old-stats-plugin: Fix context requirements Fixes Panic: Module context stats_storage_module missing Broken by 6afdf0b6fce26c5492d5e56f6f16fb8a4d869566 --- src/plugins/old-stats/stats-plugin.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/plugins/old-stats/stats-plugin.c b/src/plugins/old-stats/stats-plugin.c index 824516caed..721495ad20 100644 --- a/src/plugins/old-stats/stats-plugin.c +++ b/src/plugins/old-stats/stats-plugin.c @@ -12,6 +12,8 @@ #include "stats-plugin.h" #define STATS_CONTEXT(obj) \ + MODULE_CONTEXT(obj, stats_storage_module) +#define STATS_CONTEXT_REQUIRE(obj) \ MODULE_CONTEXT_REQUIRE(obj, stats_storage_module) /* If session isn't refreshed every 15 minutes, it's dropped. @@ -150,7 +152,7 @@ stats_transaction_begin(struct mailbox *box, const char *reason) { struct stats_user *suser = STATS_USER_CONTEXT_REQUIRE(box->storage->user); - struct stats_mailbox *sbox = STATS_CONTEXT(box); + struct stats_mailbox *sbox = STATS_CONTEXT_REQUIRE(box); struct mailbox_transaction_context *trans; struct stats_transaction_context *strans; @@ -187,8 +189,8 @@ static int stats_transaction_commit(struct mailbox_transaction_context *ctx, struct mail_transaction_commit_changes *changes_r) { - struct stats_transaction_context *strans = STATS_CONTEXT(ctx); - struct stats_mailbox *sbox = STATS_CONTEXT(ctx->box); + struct stats_transaction_context *strans = STATS_CONTEXT_REQUIRE(ctx); + struct stats_mailbox *sbox = STATS_CONTEXT_REQUIRE(ctx->box); struct stats_user *suser = STATS_USER_CONTEXT_REQUIRE(ctx->box->storage->user); stats_transaction_free(suser, strans); @@ -198,8 +200,8 @@ stats_transaction_commit(struct mailbox_transaction_context *ctx, static void stats_transaction_rollback(struct mailbox_transaction_context *ctx) { - struct stats_transaction_context *strans = STATS_CONTEXT(ctx); - struct stats_mailbox *sbox = STATS_CONTEXT(ctx->box); + struct stats_transaction_context *strans = STATS_CONTEXT_REQUIRE(ctx); + struct stats_mailbox *sbox = STATS_CONTEXT_REQUIRE(ctx->box); struct stats_user *suser = STATS_USER_CONTEXT_REQUIRE(ctx->box->storage->user); stats_transaction_free(suser, strans); @@ -209,7 +211,7 @@ stats_transaction_rollback(struct mailbox_transaction_context *ctx) static bool stats_search_next_nonblock(struct mail_search_context *ctx, struct mail **mail_r, bool *tryagain_r) { - struct stats_mailbox *sbox = STATS_CONTEXT(ctx->transaction->box); + struct stats_mailbox *sbox = STATS_CONTEXT_REQUIRE(ctx->transaction->box); struct mail_user *user = ctx->transaction->box->storage->user; struct stats_user *suser = STATS_USER_CONTEXT_REQUIRE(user); bool ret; @@ -234,7 +236,7 @@ static bool stats_search_next_nonblock(struct mail_search_context *ctx, static void stats_notify_ok(struct mailbox *box, const char *text, void *context) { - struct stats_storage *sstorage = STATS_CONTEXT(box->storage); + struct stats_storage *sstorage = STATS_CONTEXT_REQUIRE(box->storage); /* most importantly we want to refresh stats for very long running mailbox syncs */ -- 2.47.3