Skip to content

Commit

Permalink
push-notification: Resolve confusion about msg->seq
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
cmouse committed Oct 3, 2018
1 parent a6d0b68 commit 31485c6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions src/plugins/push-notification/push-notification-txn-msg.c
Expand Up @@ -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),
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/push-notification/push-notification-txn-msg.h
Expand Up @@ -17,7 +17,7 @@ struct push_notification_txn_msg {
ARRAY(struct push_notification_txn_event *) eventdata;

/* Private */
unsigned int seq;
unsigned int save_idx;
};


Expand Down

0 comments on commit 31485c6

Please sign in to comment.