I can generate the UID once I create the uidlist lock, and the UID is incremental globally.
Some questions: 1, Whether I can write the mail to tmp/ after creating dovecot-uidlist.lock? 2, I did the 5 steps manually, found that new mail is set to OLD flag, so that when SELECT command, it told there was no NEW mail. Looks like need to change code in maildir_uidlist_sync_next_uid()? 3, About the dovecot-uidlist.lock file creation and deletion, I checked the code, there are functions in dovecot like maildir_uidlist_lock_timeout and maildir_uidlist_unlock. If I did that via calling these functions, there are lots of extra codes need to call(like auth, mailbox open...). So the question is if I do that in my codes, how to handle the race condition correctly? (At least there would be other sessions want to lock the files also / already locked it while I want to create the dovecot-uidlist.lock)
Thanks.
Timo Sirainen
<tss@iki.fi>
Sent by: To
dovecot-bounces@d Dovecot Mailing List
ovecot.org <dovecot@dovecot.org>
cc
02/15/2012 10:19 Subject
AM Re: [Dovecot] index synchronization
during local delivery
Please respond to
Dovecot Mailing
List
<dovecot@dovecot.
org>
On 14.2.2012, at 5.31, Andy YB Hu wrote:
Now our system will take dovecot as the whole imap back end, and keep the LDA of ours, But our system has our own UID generation mechanism (in dovecot it's incremental from 1), which will be done while local delivery, So when local deliveries, it will first generate the UID, move the mail into maildir, then synchronize the mailbox index, which is part of dovecot LDA does. The question is what API or something else about index synchronization I can integrate into our own LDA program easily? Seems mailbox_copy() would be the possibility?
If you want it to be free of race conditions:
- Write the mail to tmp/
- Create dovecot-uidlist.lock
- Generate the UID and move the mail to new/ or cur/
- Append a line to dovecot-uidlist with your UID and the Maildir filename
- Delete dovecot-uidlist.lock
Although it sounds like the UID is generated before you can even create uidlist lock? That means IMAP client can at the same time generate a conflicting UID with APPEND/COPY. Also remember that UIDs must always be increasing. If you try to add a new message with lower UID then Dovecot won't like it, and even if you fix that, some IMAP clients may never see the mail.
Anyway, once you have uidlist updated you can do indexing/caching with e.g. "doveadm index" command in v2.0.