diff options
author | Guilhem Moulin <guilhem@fripost.org> | 2016-03-12 23:43:19 +0100 |
---|---|---|
committer | Guilhem Moulin <guilhem@fripost.org> | 2016-03-12 23:43:19 +0100 |
commit | b89ff54eb28bbbf25d3bf6634a6055d014beaebf (patch) | |
tree | 13bbfa9ae2bda0f12b120c927704f715e7bf2392 /pullimap | |
parent | 57fea56536c93a9727316536001ee37da0d12e60 (diff) | |
parent | 4e58fda1ae50b7fce11c567dc23dc814ce948e22 (diff) |
Merge branch 'master' into debian
Diffstat (limited to 'pullimap')
-rwxr-xr-x | pullimap | 9 |
1 files changed, 4 insertions, 5 deletions
@@ -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/; @@ -82,10 +82,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: $!"; }; @@ -141,6 +140,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'); @@ -344,7 +344,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(); } |