Mailbox locking
Hi,
while trying to avoid fixing the Mail::Audit bugs, I've run
into the same mbox locking problem with Email::LocalDelivery.
Oh well.
Upstream is still using simply flock(LOCK_EX). Debian policy says
"use fcntl() first and dot locking after this".
Using fcntl() locks from Perl seems a bit tricky, since I'll have to
pack() the lock argument together myself. I need some advice here.
The corresponding struct in /usr/include/bits/fcntl.h is
struct flock
{
short int l_type; /* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK. */
short int l_whence; /* Where `l_start' is relative to (like `lseek'). */
#ifndef __USE_FILE_OFFSET64
__off_t l_start; /* Offset where the lock begins. */
__off_t l_len; /* Size of the locked area; zero means until EOF. */
#else
__off64_t l_start; /* Offset where the lock begins. */
__off64_t l_len; /* Size of the locked area; zero means until EOF. */
#endif
__pid_t l_pid; /* Process holding the lock. */
};
I'm a bit worried about the __off64_t stuff. Can I assume that these are
of the 'l' type for pack()? What about pid_t? The best hit on Google I found,
<http://pleac.sourceforge.net/include/perl/ch07/lockarea>, has
my $FLOCK_STRUCT = 's s l l i';
The dotlocking part is easy to do by execing dotlockfile(1) from liblockfile1;
it can't be done inside the module because it needs setgid mail privileges.
Cheers,
--
Niko
Reply to: