]> git.sommitrealweird.co.uk Git - onak.git/blobdiff - onak-mail.pl
Log total received key count.
[onak.git] / onak-mail.pl
index 1c3647c9720f6493393cda7f1f031abf40b8d181..6799b3d86b4c897fd41aacc25bdf03f912f60b61 100755 (executable)
@@ -6,10 +6,9 @@
 # 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 $
-#
 
 use strict;
 
 use strict;
+use Fcntl ':flock';
 use IPC::Open3;
 
 my %config;
 use IPC::Open3;
 
 my %config;
@@ -38,6 +37,8 @@ sub readconfig {
                        $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;
                }
@@ -59,6 +60,10 @@ sub submitupdate {
        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");
 
@@ -69,6 +74,9 @@ sub submitupdate {
        @errors = <MERGEERR>;
        close MERGEERR;
 
        @errors = <MERGEERR>;
        close MERGEERR;
 
+       flock(LOCKFILE, LOCK_UN);
+       close(LOCKFILE);
+
        return @mergedata;
 }
 
        return @mergedata;
 }