From d4f52ae67f007ceacfc1a3ea2d0678600b0df73d Mon Sep 17 00:00:00 2001 From: Guilhem Moulin Date: Sat, 12 Mar 2016 00:52:04 +0100 Subject: Net::IMAP::InterIMAP: set binmode on the socket (and our pipe ends) --- pullimap | 1 + 1 file changed, 1 insertion(+) (limited to 'pullimap') diff --git a/pullimap b/pullimap index c8d4018..8eb2ac0 100755 --- a/pullimap +++ b/pullimap @@ -142,6 +142,7 @@ sub sendmail($$) { next if $! == EINTR; # try again if connect(2) was interrupted by a signal die "connect: $!"; } + binmode($SMTP) // die "binmode: $!"; smtp_resp('220'); my @r = smtp_send($ehlo => '250'); -- cgit v1.2.3 From 85fd56f6f150dba0d74859a9d5e00f16d6b33955 Mon Sep 17 00:00:00 2001 From: Guilhem Moulin Date: Sat, 12 Mar 2016 22:14:39 +0100 Subject: Net::IMAP::InterIMAP, interimap: Add support for IMAP NOTIFY [RFC 5465]. Unsollicited LIST responses are currently ignored, hence interimap won't detect mailbox creation/deletion/subcription/unsubscription. --- pullimap | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'pullimap') diff --git a/pullimap b/pullimap index 8eb2ac0..3eb2b52 100755 --- a/pullimap +++ b/pullimap @@ -346,7 +346,6 @@ unless (defined $CONFIG{idle}) { $CONFIG{idle} = 1740 if defined $CONFIG{idle} and $CONFIG{idle} == 0; # 29 mins while(1) { - my $r = $IMAP->idle($CONFIG{idle}, sub() { $IMAP->has_new_mails($MAILBOX) }); - pull() if $r; + pull() if $IMAP->idle($CONFIG{idle}, \&Net::IMAP::InterIMAP::has_new_mails); purge(); } -- cgit v1.2.3 From 4e58fda1ae50b7fce11c567dc23dc814ce948e22 Mon Sep 17 00:00:00 2001 From: Guilhem Moulin Date: Sat, 12 Mar 2016 23:38:53 +0100 Subject: pullimap: use fcntl(2) not flock(2) to lock the statefile. --- pullimap | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'pullimap') diff --git a/pullimap b/pullimap index 3eb2b52..317e880 100755 --- a/pullimap +++ b/pullimap @@ -25,7 +25,7 @@ our $VERSION = '0.3'; my $NAME = 'pullimap'; use Errno 'EINTR'; -use Fcntl qw/O_CREAT O_RDWR O_DSYNC LOCK_EX SEEK_SET F_GETFD F_SETFD FD_CLOEXEC/; +use Fcntl qw/O_CREAT O_RDWR O_DSYNC F_SETLK F_WRLCK SEEK_SET F_GETFD F_SETFD FD_CLOEXEC/; use Getopt::Long qw/:config posix_default no_ignore_case gnu_getopt auto_version/; use List::Util 'first'; use Socket qw/PF_INET PF_INET6 SOCK_STREAM/; @@ -83,10 +83,9 @@ do { } sysopen($STATE, $statefile, O_CREAT|O_RDWR|O_DSYNC, 0600) or die "Can't open $statefile: $!"; + fcntl($STATE, F_SETLK, pack('sslll', F_WRLCK, SEEK_SET, 0, 0, $$)) or die "Can't lock $statefile: $!"; my $flags = fcntl($STATE, F_GETFD, 0) or die "fcntl F_GETFD: $!"; fcntl($STATE, F_SETFD, $flags | FD_CLOEXEC) or die "fcntl F_SETFD: $!"; - - flock($STATE, LOCK_EX) or die "Can't flock $statefile: $!"; }; -- cgit v1.2.3