aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xinterimap28
1 files changed, 4 insertions, 24 deletions
diff --git a/interimap b/interimap
index 59ff0cf..d331183 100755
--- a/interimap
+++ b/interimap
@@ -77,7 +77,7 @@ my $CONF = read_config( delete $CONFIG{config} // $NAME
, 'list-select-opts' => qr/\A([\x21\x23\x24\x26\x27\x2B-\x5B\x5E-\x7A\x7C-\x7E]+)\z/
, 'ignore-mailbox' => qr/\A([\x01-\x09\x0B\x0C\x0E-\x7F]+)\z/
);
-my ($DBFILE, $LOCKFILE, $LOGGER_FD);
+my ($DBFILE, $LOGGER_FD);
{
$DBFILE = $CONF->{_}->{database} if defined $CONF->{_};
@@ -95,8 +95,6 @@ my ($DBFILE, $LOCKFILE, $LOGGER_FD);
}
}
- $LOCKFILE = $DBFILE =~ s/([^\/]+)\z/.$1.lck/r;
-
if (defined $CONF->{_} and defined $CONF->{_}->{logfile}) {
require 'POSIX.pm';
require 'Time/HiRes.pm';
@@ -117,7 +115,6 @@ my ($IMAP, $lIMAP, $rIMAP);
sub cleanup() {
undef $_ foreach grep defined, ($IMAP, $lIMAP, $rIMAP);
logger(undef, "Cleaning up...") if $CONFIG{debug};
- unlink $LOCKFILE if defined $LOCKFILE and -f $LOCKFILE;
close $LOGGER_FD if defined $LOGGER_FD;
$DBH->disconnect() if defined $DBH;
}
@@ -126,33 +123,16 @@ $SIG{TERM} = sub { cleanup(); exit 0; };
#############################################################################
-# Lock the database
-{
- if (-f $LOCKFILE) {
- open my $lock, '<', $LOCKFILE or die "Can't open $LOCKFILE: $!\n";
- my $pid = <$lock>;
- close $lock;
- chomp $pid;
- my $msg = "LOCKFILE '$LOCKFILE' exists.";
- undef $LOCKFILE; # don't delete the lockfile
- $msg .= " (Is PID $pid running?)" if defined $pid and $pid =~ /^[0-9]+$/;
- die $msg, "\n";
- }
-
- open my $lock, '>', $LOCKFILE or die "Can't open $LOCKFILE: $!\n";
- print $lock $$, "\n";
- close $lock;
-}
-
-
-#############################################################################
# Open the database and create tables
$DBH = DBI::->connect("dbi:SQLite:dbname=$DBFILE", undef, undef, {
AutoCommit => 0,
RaiseError => 1,
sqlite_see_if_its_a_number => 1, # see if the bind values are numbers or not
+ sqlite_use_immediate_transaction => 1,
});
+$DBH->sqlite_busy_timeout(250);
+$DBH->do('PRAGMA locking_mode = EXCLUSIVE');
$DBH->do('PRAGMA foreign_keys = ON');