Skip to content

Commit

Permalink
old-stats-plugin: Fix context requirements
Browse files Browse the repository at this point in the history
Fixes Panic: Module context stats_storage_module missing

Broken by 6afdf0b
  • Loading branch information
cmouse authored and mrannanj committed Feb 20, 2018
1 parent 6ff5704 commit 511fba2
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/plugins/old-stats/stats-plugin.c
Expand Up @@ -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.
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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;
Expand All @@ -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 */
Expand Down

0 comments on commit 511fba2

Please sign in to comment.