r1713 - in packages/libemail-localdelivery-perl/trunk/debian: .
patches
Niko Tyni
ntyni-guest at costa.debian.org
Tue Dec 20 18:09:48 UTC 2005
Author: ntyni-guest
Date: 2005-12-20 18:09:47 +0000 (Tue, 20 Dec 2005)
New Revision: 1713
Added:
packages/libemail-localdelivery-perl/trunk/debian/patches/10mbox-locking.dpatch
Modified:
packages/libemail-localdelivery-perl/trunk/debian/changelog
packages/libemail-localdelivery-perl/trunk/debian/control
Log:
First try at policy-compliant mbox locking.
Modified: packages/libemail-localdelivery-perl/trunk/debian/changelog
===================================================================
--- packages/libemail-localdelivery-perl/trunk/debian/changelog 2005-12-20 10:37:14 UTC (rev 1712)
+++ packages/libemail-localdelivery-perl/trunk/debian/changelog 2005-12-20 18:09:47 UTC (rev 1713)
@@ -1,6 +1,8 @@
libemail-localdelivery-perl (0.09-1) unstable; urgency=low
* Initial Release. (Closes: #194548)
+ * debian/patches:
+ + 10mbox-locking.dpatch: Policy-compliant mbox locking (hopefully)
- -- Niko Tyni <ntyni at iki.fi> Tue, 20 Dec 2005 00:01:35 +0200
+ -- Niko Tyni <ntyni at iki.fi> Tue, 20 Dec 2005 19:13:01 +0200
Modified: packages/libemail-localdelivery-perl/trunk/debian/control
===================================================================
--- packages/libemail-localdelivery-perl/trunk/debian/control 2005-12-20 10:37:14 UTC (rev 1712)
+++ packages/libemail-localdelivery-perl/trunk/debian/control 2005-12-20 18:09:47 UTC (rev 1713)
@@ -2,14 +2,14 @@
Section: perl
Priority: optional
Build-Depends: debhelper (>= 5), dpatch
-Build-Depends-Indep: perl (>= 5.8.0-7), libfile-path-expand-perl (>= 1.01-1), libemail-foldertype-perl (>= 0.7-1), libemail-simple-perl (>= 1.92-0.1)
+Build-Depends-Indep: perl (>= 5.8.0-7), libfile-path-expand-perl (>= 1.01-1), libemail-foldertype-perl (>= 0.7-1), libemail-simple-perl (>= 1.92-0.1), liblockfile1 (>= 1.0-1)
Maintainer: Debian Perl Group <pkg-perl-maintainers at lists.alioth.debian.org>
Uploaders: Niko Tyni <ntyni at iki.fi>
Standards-Version: 3.6.2
Package: libemail-localdelivery-perl
Architecture: all
-Depends: ${perl:Depends}, ${misc:Depends}, libfile-path-expand-perl (>= 1.01-1), libemail-foldertype-perl (>= 0.7-1), libemail-simple-perl (>= 1.92-0.1)
+Depends: ${perl:Depends}, ${misc:Depends}, libfile-path-expand-perl (>= 1.01-1), libemail-foldertype-perl (>= 0.7-1), libemail-simple-perl (>= 1.92-0.1), liblockfile1 (>= 1.0-1)
Description: Deliver a piece of email - simply
Email::LocalDelivery delivers an email to a list of mailboxes.
.
Added: packages/libemail-localdelivery-perl/trunk/debian/patches/10mbox-locking.dpatch
===================================================================
--- packages/libemail-localdelivery-perl/trunk/debian/patches/10mbox-locking.dpatch 2005-12-20 10:37:14 UTC (rev 1712)
+++ packages/libemail-localdelivery-perl/trunk/debian/patches/10mbox-locking.dpatch 2005-12-20 18:09:47 UTC (rev 1713)
@@ -0,0 +1,119 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 10mbox-locking.dpatch by Niko Tyni <ntyni at iki.fi>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Policy-compliant mbox locking (hopefully).
+
+ at DPATCH@
+diff -urNad trunk~/LocalDelivery/Mbox.pm trunk/LocalDelivery/Mbox.pm
+--- trunk~/LocalDelivery/Mbox.pm 2005-12-20 00:42:20.000000000 +0200
++++ trunk/LocalDelivery/Mbox.pm 2005-12-20 20:06:53.250575574 +0200
+@@ -2,7 +2,7 @@
+ use File::Path;
+ use File::Basename;
+ use Email::Simple;
+-use Fcntl ':flock';
++use Fcntl;
+
+ our $VERSION = "1.07";
+
+@@ -15,7 +15,7 @@
+ print $fh $class->_from_line(\$mail); # Avoid passing $mail where poss.
+ print $fh $class->_escape_from_body(\$mail);
+ print $fh "\n" unless $mail =~ /\n$/;
+- $class->_close_fh($fh) || next;
++ $class->_close_fh($fh, $file) || next;
+ push @rv, $file
+ }
+ return @rv;
+@@ -27,14 +27,14 @@
+ return if ! -d $dir and not mkpath($dir);
+
+ open my $fh, ">> $file" or return;
+- $class->getlock($fh) || return;
++ $class->getlock($fh, $file) || return;
+ seek $fh, 0, 2;
+ return $fh;
+ }
+
+ sub _close_fh {
+- my ($class, $fh) = @_;
+- $class->unlock($fh) || return;
++ my ($class, $fh, $file) = @_;
++ $class->unlock($fh, $file) || return;
+ close $fh or return;
+ return 1;
+ }
+@@ -79,17 +79,69 @@
+ }
+
+ sub getlock {
++ my ($class, $fh, $file) = @_;
++ for (1..10) {
++ return 0 unless $class->getlock_fcntl($fh);
++ return 1 if $class->getlock_dotlock($file);
++ sleep int(rand(10 * $_));
++ }
++ $class->unlock_fcntl($fh);
++ return 0;
++
++}
++
++sub getlock_fcntl {
+ my ($class, $fh) = @_;
++ my $lock = pack('s at 256', F_WRLCK);
+ for (1..10) {
+- return 1 if flock ($fh, LOCK_EX | LOCK_NB);
++ return 1 if fcntl($fh, F_SETLK, $lock);
+ sleep $_;
+ }
+ return 0 ;
+ }
+
++sub getlock_dotlock {
++ my ($class, $file) = @_;
++ my $lockfile = $file . ".lock";
++ my $cmd = "/usr/bin/dotlockfile";
++ system($cmd, $lockfile);
++ return 1 unless $?;
++ if ($? == -1) {
++ die("Couldn't exec $cmd: $!");
++ }
++ if ($? & 127) {
++ warn("$cmd exited with signal " . ($? & 127));
++ }
++ return 0;
++}
++
+ sub unlock {
+- my ($class,$fh) = @_;
+- flock ($fh, LOCK_UN);
++ my ($class,$fh, $file) = @_;
++ return 0 unless $class->unlock_dotlock($file);
++ return 0 unless $class->unlock_fcntl($fh);
++ return 1;
++}
++
++sub unlock_fcntl {
++ my ($class, $fh) = @_;
++ my $lock = pack('s at 256', F_UNLCK);
++ return 1 if fcntl($fh, F_SETLK, $lock);
++ return 0;
++}
++
++sub unlock_dotlock {
++ my ($class, $file) = @_;
++ my $lockfile = $file . ".lock";
++ my $cmd = "/usr/bin/dotlockfile";
++ system($cmd, "-u", $lockfile);
++ return 1 unless $?;
++ if ($? == -1) {
++ die("Couldn't exec $cmd: $!");
++ }
++ if ($? & 127) {
++ warn("$cmd exited with signal " . ($? & 127));
++ }
++ return 0;
+ }
+
+ 1;
Property changes on: packages/libemail-localdelivery-perl/trunk/debian/patches/10mbox-locking.dpatch
___________________________________________________________________
Name: svn:executable
+ *
More information about the Pkg-perl-cvs-commits
mailing list