Sam Varshavchik wrote:
You're missing the point. Consider two delivery attempts running
simultaneously, the mailing list folder does not exist.
if ( this is a mailing list )
{
exception {
to "${VMAILDIR}/.${LISTS}.${MATCH2}/"
}
First of all, as you know, if the file does not exist, maildrop, for
legacy reasons, creates an mbox file.
You want, instead: to "${VMAILDIR}/.${LISTS}.${MATCH2}/."
Hmmm. I don't see this behaviour. Where does the mbox file get created?
Anyway, with that correction in place, both delivery attempts fail
here, and fall through.
exception {
flock lockfile_${MATCH2} {
`${MAILDIRMAKE} -f ${LISTS}.${MATCH2} ${VMAILDIR}`
}
Delivery attempt #1 grabs the lock. Delivery attempt #2 waits for
the lock to be released. Delivery attempt #1 creates the folder,
releases the lock.
Then, delivery attempt takes the lock that it's been waiting on, and
tries to create the folder itself, and fails, and the exception falls
through, and the message is not delivered.
When flock cannot take the lock immediately, it waits for the lock to
be released. Once the lock is obtained it STILL executed the
instructions inside the flock statement. That's what you need to
remember.
OK, I think that makes things clearer.
I need something like:
if ( is a mailing list )
{
flock lockfile {
exception {
to mailing_list_maildir
}
exception {
create new mailing_list_maildir
to mailing_list_maildir
}
}
}
Actually, I think a better solution would be:
if ( is a mailing list )
{
flock lockfile {
if mailing_list_maildir doesn't exist
{
create new mailing_list_maildir
}
}
exception {
to mailing_list_maildir
}
to defaultdelivery
}
Would you agree? If so, how can I check for the existence of the maildir before
attempting delivery?
Thanks,
R>