]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
push-notification: Resolve confusion about msg->seq
authorAki Tuomi <aki.tuomi@dovecot.fi>
Wed, 3 Oct 2018 09:00:55 +0000 (12:00 +0300)
committerVille Savolainen <ville.savolainen@dovecot.fi>
Wed, 14 Nov 2018 12:01:53 +0000 (14:01 +0200)
It's not the same seq what the mail has, but a sequence that
is used to find out UID for saved mails. So rename it to
save_idx and treat it accordingly. Note that save_idx is 0
based, and mail sequence is 1 based.

src/plugins/push-notification/push-notification-txn-msg.c
src/plugins/push-notification/push-notification-txn-msg.h

index b8cb552bf6c8fac9877a96f62efcd08e9eee7341..7a9e3de000d8d161b1299ed380610301dc352075 100644 (file)
@@ -26,7 +26,10 @@ push_notification_txn_msg_create(struct push_notification_txn *txn,
         msg = p_new(txn->pool, struct push_notification_txn_msg, 1);
         msg->mailbox = mailbox_get_vname(mail->box);
         /* Save sequence number - used to determine UID later. */
-        msg->seq = txn->t->save_count;
+       if (mail->uid == 0)
+               msg->save_idx = txn->t->save_count;
+       else
+               msg->save_idx = UINT_MAX;
         msg->uid = mail->uid;
 
         hash_table_insert(txn->messages, POINTER_CAST(mail->seq),
@@ -65,10 +68,11 @@ push_notification_txn_msg_end(struct push_notification_txn *ptxn,
 
     while (hash_table_iterate(hiter, ptxn->messages, &key, &value)) {
         if (value->uid == 0) {
-            if (seq_range_array_iter_nth(&siter, value->seq, &uid)) {
+            if (seq_range_array_iter_nth(&siter, value->save_idx, &uid)) {
                 value->uid = uid;
             }
-        }
+        } else
+               i_assert(value->save_idx == UINT_MAX);
         value->uid_validity = uid_validity;
 
         array_foreach_modifiable(&ptxn->drivers, dtxn) {
index c743b7a12833310b03de9346768cd63a523c724b..f0cacbb07490855a3f14a1f5bf20ee8f6e83314e 100644 (file)
@@ -17,7 +17,7 @@ struct push_notification_txn_msg {
     ARRAY(struct push_notification_txn_event *) eventdata;
 
     /* Private */
-    unsigned int seq;
+    unsigned int save_idx;
 };