# HG changeset patch # User Timo Sirainen # Date 1497773968 -10800 # Node ID 9be64b864597fe9ca747204a804c6295b732fbab # Parent 72574d93be61a9eecdf03a16b6479f04dd89a6ce imap: NOTIFY - Fix delayed setting notification callback This was done in command-post hook, but then when command was soon freed the callback was immediately added. diff -r 72574d93be61 -r 9be64b864597 src/imap/imap-notify.c --- a/src/imap/imap-notify.c Mon Jun 19 09:22:56 2017 +0300 +++ b/src/imap/imap-notify.c Sun Jun 18 11:19:28 2017 +0300 @@ -436,7 +436,19 @@ void imap_client_notify_command_freed(struct client *client) { - imap_notify_watch_selected_mailbox(client); + struct imap_notify_context *ctx = client->notify_ctx; + + if (ctx == NULL) + return; + + /* add mailbox watched back after a small delay */ + if (ctx->to_watch != NULL) + timeout_reset(ctx->to_watch); + else { + ctx->to_watch = timeout_add(IMAP_NOTIFY_WATCH_ADD_DELAY_MSECS, + imap_notify_watch_timeout, + client); + } } static void imap_notify_cmd_hook_pre(struct client_command_context *cmd) @@ -455,23 +467,6 @@ timeout_remove(&ctx->to_watch); } -static void imap_notify_cmd_hook_post(struct client_command_context *cmd) -{ - struct imap_notify_context *ctx = cmd->client->notify_ctx; - - if (ctx == NULL) - return; - - /* add mailbox watched back after a small delay */ - if (ctx->to_watch != NULL) - timeout_reset(ctx->to_watch); - else { - ctx->to_watch = timeout_add(IMAP_NOTIFY_WATCH_ADD_DELAY_MSECS, - imap_notify_watch_timeout, - cmd->client); - } -} - int imap_notify_begin(struct imap_notify_context *ctx) { struct imap_notify_namespace *notify_ns; @@ -481,8 +476,7 @@ if (!notify_hook_registered) { notify_hook_registered = TRUE; - command_hook_register(imap_notify_cmd_hook_pre, - imap_notify_cmd_hook_post); + command_hook_register(imap_notify_cmd_hook_pre, NULL); } array_foreach_modifiable(&ctx->namespaces, notify_ns) {