From 7f1c2d9ec737a90d4d216f59ccb8b93f9054c472 Mon Sep 17 00:00:00 2001 From: Jonathan McDowell Date: Mon, 31 May 2004 23:48:11 +0000 Subject: [PATCH] cscvs to tla changeset 116 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. --- onak-mail.pl | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/onak-mail.pl b/onak-mail.pl index 1c3647c..e5c0d04 100755 --- a/onak-mail.pl +++ b/onak-mail.pl @@ -6,10 +6,11 @@ # 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 strict; +use Fcntl ':flock'; use IPC::Open3; my %config; @@ -38,6 +39,8 @@ sub readconfig { $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; } @@ -59,6 +62,10 @@ sub submitupdate { 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"); @@ -69,6 +76,9 @@ sub submitupdate { @errors = ; close MERGEERR; + flock(LOCKFILE, LOCK_UN); + close(LOCKFILE); + return @mergedata; } -- 2.39.5