diff --git a/src/plugins/old-stats/mail-stats-connection.c b/src/plugins/old-stats/mail-stats-connection.c index 0e131e332f..ca20fcb517 100644 --- a/src/plugins/old-stats/mail-stats-connection.c +++ b/src/plugins/old-stats/mail-stats-connection.c @@ -14,7 +14,7 @@ int mail_stats_connection_connect(struct stats_connection *conn, struct mail_user *user) { - struct stats_user *suser = STATS_USER_CONTEXT(user); + struct stats_user *suser = STATS_USER_CONTEXT_REQUIRE(user); string_t *str = t_str_new(128); str_append(str, "CONNECT\t"); @@ -42,7 +42,7 @@ int mail_stats_connection_connect(struct stats_connection *conn, void mail_stats_connection_disconnect(struct stats_connection *conn, struct mail_user *user) { - struct stats_user *suser = STATS_USER_CONTEXT(user); + struct stats_user *suser = STATS_USER_CONTEXT_REQUIRE(user); string_t *str = t_str_new(128); str_append(str, "DISCONNECT\t"); @@ -58,7 +58,7 @@ void mail_stats_connection_send_session(struct stats_connection *conn, struct mail_user *user, const struct stats *stats) { - struct stats_user *suser = STATS_USER_CONTEXT(user); + struct stats_user *suser = STATS_USER_CONTEXT_REQUIRE(user); string_t *str = t_str_new(256); buffer_t *buf; diff --git a/src/plugins/old-stats/stats-plugin.c b/src/plugins/old-stats/stats-plugin.c index cad0a49bdb..824516caed 100644 --- a/src/plugins/old-stats/stats-plugin.c +++ b/src/plugins/old-stats/stats-plugin.c @@ -12,7 +12,7 @@ #include "stats-plugin.h" #define STATS_CONTEXT(obj) \ - MODULE_CONTEXT(obj, stats_storage_module) + MODULE_CONTEXT_REQUIRE(obj, stats_storage_module) /* If session isn't refreshed every 15 minutes, it's dropped. Must be smaller than MAIL_SESSION_IDLE_TIMEOUT_MSECS in stats server */ @@ -47,7 +47,7 @@ static void session_stats_refresh_timeout(struct mail_user *user); static void stats_io_activate(struct mail_user *user) { - struct stats_user *suser = STATS_USER_CONTEXT(user); + struct stats_user *suser = STATS_USER_CONTEXT_REQUIRE(user); struct mail_stats *mail_stats; if (stats_user_count == 1) { @@ -67,7 +67,7 @@ static void stats_io_activate(struct mail_user *user) static void stats_add_session(struct mail_user *user) { - struct stats_user *suser = STATS_USER_CONTEXT(user); + struct stats_user *suser = STATS_USER_CONTEXT_REQUIRE(user); struct stats *new_stats, *diff_stats; const char *error; @@ -120,7 +120,7 @@ session_stats_need_send(struct stats_user *suser, time_t now, static void session_stats_refresh(struct mail_user *user) { - struct stats_user *suser = STATS_USER_CONTEXT(user); + struct stats_user *suser = STATS_USER_CONTEXT_REQUIRE(user); unsigned int to_next_secs; time_t now = time(NULL); bool changed; @@ -149,7 +149,7 @@ stats_transaction_begin(struct mailbox *box, enum mailbox_transaction_flags flags, const char *reason) { - struct stats_user *suser = STATS_USER_CONTEXT(box->storage->user); + struct stats_user *suser = STATS_USER_CONTEXT_REQUIRE(box->storage->user); struct stats_mailbox *sbox = STATS_CONTEXT(box); struct mailbox_transaction_context *trans; struct stats_transaction_context *strans; @@ -189,7 +189,7 @@ stats_transaction_commit(struct mailbox_transaction_context *ctx, { struct stats_transaction_context *strans = STATS_CONTEXT(ctx); struct stats_mailbox *sbox = STATS_CONTEXT(ctx->box); - struct stats_user *suser = STATS_USER_CONTEXT(ctx->box->storage->user); + struct stats_user *suser = STATS_USER_CONTEXT_REQUIRE(ctx->box->storage->user); stats_transaction_free(suser, strans); return sbox->module_ctx.super.transaction_commit(ctx, changes_r); @@ -200,7 +200,7 @@ 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_user *suser = STATS_USER_CONTEXT(ctx->box->storage->user); + struct stats_user *suser = STATS_USER_CONTEXT_REQUIRE(ctx->box->storage->user); stats_transaction_free(suser, strans); sbox->module_ctx.super.transaction_rollback(ctx); @@ -211,7 +211,7 @@ static bool stats_search_next_nonblock(struct mail_search_context *ctx, { struct stats_mailbox *sbox = STATS_CONTEXT(ctx->transaction->box); struct mail_user *user = ctx->transaction->box->storage->user; - struct stats_user *suser = STATS_USER_CONTEXT(user); + struct stats_user *suser = STATS_USER_CONTEXT_REQUIRE(user); bool ret; ret = sbox->module_ctx.super. @@ -289,7 +289,7 @@ static void session_stats_refresh_timeout(struct mail_user *user) static void stats_io_deactivate(struct mail_user *user) { - struct stats_user *suser = STATS_USER_CONTEXT(user); + struct stats_user *suser = STATS_USER_CONTEXT_REQUIRE(user); unsigned int last_update_secs; if (stats_global_user == NULL) @@ -309,7 +309,7 @@ static void stats_io_deactivate(struct mail_user *user) static void stats_user_stats_fill(struct mail_user *user, struct stats *stats) { - struct stats_user *suser = STATS_USER_CONTEXT(user); + struct stats_user *suser = STATS_USER_CONTEXT_REQUIRE(user); struct mail_stats *mail_stats; mail_stats = stats_fill_ptr(stats, mail_stats_item); @@ -320,7 +320,7 @@ static void stats_user_stats_fill(struct mail_user *user, struct stats *stats) static void stats_user_deinit(struct mail_user *user) { - struct stats_user *suser = STATS_USER_CONTEXT(user); + struct stats_user *suser = STATS_USER_CONTEXT_REQUIRE(user); struct stats_connection *stats_conn = suser->stats_conn; i_assert(stats_user_count > 0); diff --git a/src/plugins/old-stats/stats-plugin.h b/src/plugins/old-stats/stats-plugin.h index 3462d2407a..33e0aedd94 100644 --- a/src/plugins/old-stats/stats-plugin.h +++ b/src/plugins/old-stats/stats-plugin.h @@ -8,6 +8,9 @@ #define STATS_USER_CONTEXT(obj) \ MODULE_CONTEXT(obj, stats_user_module) +#define STATS_USER_CONTEXT_REQUIRE(obj) \ + MODULE_CONTEXT_REQUIRE(obj, stats_user_module) + struct stats_user { union mail_user_module_context module_ctx;