Re: Maildir lock problem

Marco Paganini <[email protected]>
Newsgroups gmane.mail.spam.active-spam-killer.general
Message-ID <[email protected]>
Hello Steven,

> There seems to be an inconsistency in the deliver_mail method of
> askmail.py with regard to locking. In the case of an mbox type of
> mailbox, the locking mechanism uses the rc_lockfile configuration
> value if it is defined, but for a Maildir type of mailbox it does not.
> 
> Since I am using NFS, I need to specify an rc_lockfile so that the
> file locking mechanism works. I am also using Maildir, and when I try
> to run a remote command that requires the delivery of a queued
> message, I would get a "No locks available" message.
> 
> I have hacked the askmail.py file to do essentially the same thing for
> a Maildir type of mailbox as is done for an mbox type, and that fixes
> the error. Is there something I am overlooking that will cause me
> problems?

Maildir deliveries do not need file locking. This is so because maildir files
have unique names, so no contention should occur. Note that the code tests
for the existence of a file and generates a new name if that file already
exists.

However...

You just pointed me a problem with ASK: It still tries to lock maildir
files and does not obey the rc_lockfile setting. I'd say the easiest way
to go about this is to remove locking altogether when delivery is being
performed in Maildir mode. I'll code these changes on 2.5.1 (CVS) right
now. For the meantime, if you want to change the code:

In askmail.py:

Look for something like:

	if not (os.path.exists(maildir_file) or os.path.exists(maildir_file_new)):
		fh_mbox = lck.open(maildir_file, "w")
		break
	else:

And change it to:

	if not (os.path.exists(maildir_file) or os.path.exists(maildir_file_new)):
		fh_mbox = open(maildir_file, "w")
		break
	else:

Also, look for something like:

	## Unlock and close
	if (using_stdout == 0 and using_pipe == 0):
		lck.close()

	## Pipe delivery closes normally
	if using_pipe:
		fh_mbox.close()

And change it to:

	## Unlock and close
	if (using_stdout == 0 and using_pipe == 0 and using_maildir == 0):
		lck.close()

	## Pipe delivery closes normally
	if using_pipe or using_maildir:
		fh_mbox.close()

Pay special attention to tabs. Python is *very* picky about tabs. Set your
tabsize to 4 and make sure you indent with tabs, not spaces.

This should solve your problem. Please let me know if it works.

Regards,
Paga

-- 
Marco Paganini          | UNIX / Linux / Networking
[email protected]   | PGP: http://www.paganini.net/pgp/
http://www.paganini.net | Magnus Frater te spectat...


-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.