[Dovecot] quota and lazy_expunge plugins both used: quotas go wrong with lazy_expunge'd mails
Hello,
I may have missed a point, but I could have found an issue between plugins quota and lazy_expunge.
I have noticed that the "lazy_expunge"d mails are counted as part of the quota, while the documentation says it should not be. I have first tried to find out if this was a configuration mistake somewhere. Notably, you can notice that the expunged mails are in directory ~/expunged while the usual mail is in ~/Maildir : expunged mails are not in a subdirectory of ~/Maildir (this was just to make sure there were no side effect with this).
I have deleted some expunged mails to be sure : at its next cycle, the file ~/Maildir/maildirsize contained expected value. So yes, I do know expunged mails in the expunged directory are counted (size, number of mails).
So I've taken a look at the source code, adding some i_info(...) at different places of the quota and lazy_expunge plugins.
- In src/lazy-expunge/lazy-expunge-plugin.c 1.1. lazy_expunge_mail_storage_init() sets the expunged mails namespace flag with NAMESPACE_FLAG_NOQUOTA 1.2. lazy_expunge_mail_storage_init() is called by lazy_expunge_mail_storage_created() 1.3. lazy_expunge_mail_storage_created() is part of the callback list hook_mail_storage_create
- In src/plugins/quota/quota-storage.c: 2.1. The only place in the whole dovecot source code where NAMESPACE_FLAG_NOQUOTA is checked is in function quota_mailbox_list_created()
- In src/plugins/quota/quota-plugin.c: 3.1 quota_plugin_init() add quota_mailbox_list_created() to the callback list hook_mailbox_list_created.
From my observations :
From the source code reading session, I understand that :
- Callback functions in quota_mailbox_list_created are called _before_ callback functions in hook_mail_storage_create.
- This observation led me to move the piece of code that sets NAMESPACE_FLAG_NOQUOTA from lazy_expunge_mail_storage_init() to lazy_expunge_mail_storage_created().
- But there, lazy_expunge_mail_storage_created() is called after quota_mail_storage_created() because names of the library files are lib10_quota_plugin.so and lib02_lazy_expunge_plugin.so.
- There I have also learnt that callback functions of the same list are called in the reverse order compared to the library filenames.
So see if my observations were right, I have renamed lib10_quota_plugin.so to lib01_quota_plugin.so, then it worked.
But I doubt this is the right way to fix it. This also reverses the order other callbacks between the two plugins are called, which migh not be expected at all. I'm not event sure moving some code from lazy_expunge_mail_storage_init() to lazy_expunge_mail_storage_created() was right : I've improvized the reading the source code and do not understand the whole logic, so I suppose this could break something else.
Timo, what do you propose ?
Thanks for your great software.
-- Baptiste MALGUY PGP fingerprint: 49B0 4F6E 4AA8 B149 B2DF 9267 0F65 6C1C C473 6EC2
Hello,
In case my nasty changes are right, here comes the patch (including Makefile.in & Makefile.am ... I'm not really good with automake/autoconf) I've applied to dovecot 1.2.10 (from Debian backport repository for Lenny, source package version 1:1.2.10-1~bpo50+1, expecting my changes won't be different from the vanilla version).
Regards,
-- Baptiste MALGUY PGP fingerprint: 49B0 4F6E 4AA8 B149 B2DF 9267 0F65 6C1C C473 6EC2
On Fri, 2010-02-19 at 17:17 +0100, Baptiste Malguy wrote:
- But there, lazy_expunge_mail_storage_created() is called after quota_mail_storage_created() because names of the library files are lib10_quota_plugin.so and lib02_lazy_expunge_plugin.so.
Uh oh. This is completely the reverse of how they were supposed to be working. I'm surprised that there haven't been more problems. But it's probably a bit too dangerous to change it anymore now in v1.x. It should be fixed already with v2.0.
participants (2)
-
Baptiste Malguy
-
Timo Sirainen