summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
e3ac263)
Author: noodles
Date: 2004/01/04 18:48:37
Add a lock around the call to onak so that we've only got one copy of onak-mail
running it at once.
# Copyright 2002 Project Purple
# Released under the GPL.
#
# Copyright 2002 Project Purple
# Released under the GPL.
#
-# $Id: onak-mail.pl,v 1.8 2003/10/11 22:17:17 noodles Exp $
+# $Id: onak-mail.pl,v 1.9 2004/01/04 18:48:37 noodles Exp $
use IPC::Open3;
my %config;
use IPC::Open3;
my %config;
$config{'mta'} = $1;
} elsif (/^pks_bin_dir (.*)/) {
$config{'pks_bin_dir'} = $1;
$config{'mta'} = $1;
} elsif (/^pks_bin_dir (.*)/) {
$config{'pks_bin_dir'} = $1;
+ } elsif (/^db_dir (.*)/) {
+ $config{'db_dir'} = $1;
} elsif (/^syncsite (.*)/) {
push @{$config{'syncsites'}}, $1;
}
} elsif (/^syncsite (.*)/) {
push @{$config{'syncsites'}}, $1;
}
my @data = @_;
my (@errors, @mergedata);
my @data = @_;
my (@errors, @mergedata);
+ open(LOCKFILE, '>'.$config{'db_dir'}.'/onak-mail.lck');
+ flock(LOCKFILE, LOCK_EX);
+ print LOCKFILE "$$";
+
open3(\*MERGEIN, \*MERGEOUT, \*MERGEERR,
$config{'pks_bin_dir'}."/onak", "-u", "add");
open3(\*MERGEIN, \*MERGEOUT, \*MERGEERR,
$config{'pks_bin_dir'}."/onak", "-u", "add");
@errors = <MERGEERR>;
close MERGEERR;
@errors = <MERGEERR>;
close MERGEERR;
+ flock(LOCKFILE, LOCK_UN);
+ close(LOCKFILE);
+