On Wed, 2008-07-23 at 12:07 -0400, Daniel Brosseau
wrote:> Hi,
>
> I am new to the dovecot source and would like to know why the
> mailbox_module_context has a pointer to the mail_storage_module_register
and
> not to a mailbox_module_register.
?Hmm. I don't actually remember anymore all that much about why I did it
that way. :) Just using it is a bit too complex sometimes.. Anyway the
idea was something like:
Module context registers should provide some kind of type checking, so
that you don't accidentally use wrong type of context structures. Why
there's no mailbox_module_register I'm not sure.. I think it's
because
of 1) less registers -> less complex and 2) if you're going to set
mailbox contexts, you're very likely to set mail storage contexts as
well.
> From what I have understood, if a context
> is first added to the mailbox.module_contexts array using the
> mail_storage_module_register and then a context is added to the
> mail_storage.module_contexts and then a third context is again added to the
> mailbox.module_contexts the mail_storage_module_register.id will be 3 and
> the second element in the mailbox.module_context will be unused and the
> first and third elements of the mail_storage.module_contexts are unused.
It depends on the callers. Each module (plugin, whatever) allocates its
own unique ID from register(s) and uses it for all context structures
using the same register. So a typical usage would be like:
- plugin1: id=0, use mail_storage.module_contexts[0] and
mailbox.module_contexts[0]
- plugin2: id=1, ?use mail_storage.module_contexts[1] and
mailbox.module_contexts[1]
- etc.
The situation you describe could happen if the plugins did something
like:
- plugin1: id=0, use ONLY mail_storage.module_contexts[0]
- plugin2: id=1, use ONLY mailbox.module_contexts[1]
- plugin3: id=2, use ONLY ?mail_storage.module_contexts[2]
- etc.
But that kind of usage should be rare.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part
URL:
<http://dovecot.org/pipermail/dovecot/attachments/20080723/b8f71bb5/attachment-0002.bin>