]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
imap: NOTIFY (SUBSCRIPTIONS) assert-crashed when subscriptions hadn't been refreshed.
authorTimo Sirainen <tss@iki.fi>
Mon, 7 Sep 2015 20:08:44 +0000 (23:08 +0300)
committerTimo Sirainen <tss@iki.fi>
Mon, 7 Sep 2015 20:08:44 +0000 (23:08 +0300)
src/imap/cmd-notify.c
src/imap/imap-notify.h

index d093573c84323f3a9da41687fe05eb961edb4e9b..217da6871692a102774eba5c51043a5585c6fc9c 100644 (file)
@@ -206,11 +206,34 @@ static void cmd_notify_add_personal(struct imap_notify_context *ctx,
        }
 }
 
+static int
+imap_notify_refresh_subscriptions(struct client_command_context *cmd,
+                                 struct imap_notify_context *ctx)
+{
+       struct mailbox_list_iterate_context *iter;
+       struct mail_namespace *ns;
+
+       if (!ctx->have_subscriptions)
+               return 0;
+
+       /* make sure subscriptions are refreshed at least once */
+       for (ns = ctx->client->user->namespaces; ns != NULL; ns = ns->next) {
+               iter = mailbox_list_iter_init(ns->list, "*", MAILBOX_LIST_ITER_SELECT_SUBSCRIBED);
+               (void)mailbox_list_iter_next(iter);
+               if (mailbox_list_iter_deinit(&iter) < 0) {
+                       client_send_list_error(cmd, ns->list);
+                       return -1;
+               }
+       }
+       return 0;
+}
+
 static void cmd_notify_add_subscribed(struct imap_notify_context *ctx,
                                      enum imap_notify_event events)
 {
        struct mail_namespace *ns;
 
+       ctx->have_subscriptions = TRUE;
        for (ns = ctx->client->user->namespaces; ns != NULL; ns = ns->next) {
                cmd_notify_add_mailbox(ctx, ns, "",
                                       IMAP_NOTIFY_TYPE_SUBSCRIBED, events);
@@ -523,6 +546,10 @@ bool cmd_notify(struct client_command_context *cmd)
                        "NO [NOTIFICATIONOVERFLOW] Too many mailbox names");
                pool_unref(&pool);
                return TRUE;
+       } else if (imap_notify_refresh_subscriptions(cmd, ctx) < 0) {
+               /* tagline already sent */
+               pool_unref(&pool);
+               return TRUE;
        } else if (imap_notify_begin(ctx) < 0) {
                client_send_tagline(cmd,
                        "NO [NOTIFICATIONOVERFLOW] NOTIFY not supported for these mailboxes.");
index eef89982173f58822cb5c3c9cfc2566644e9c7a9..43f0dbbbf179346fb7094ae0842bf47d3314fb08 100644 (file)
@@ -49,6 +49,7 @@ struct imap_notify_context {
        struct imap_fetch_context *fetch_ctx;
        struct timeout *to_watch;
 
+       unsigned int have_subscriptions:1;
        unsigned int selected_set:1;
        unsigned int selected_immediate_expunges:1;
        unsigned int send_immediate_status:1;