From: Jacob Bachmeyer Date: Sun, 30 Apr 2023 02:59:12 +0000 (-0500) Subject: Add separate serials flag file for flock in gatekeeper X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=e3e3a9e62ffbacc2032cc8d5c239166d385eeb25;p=gatekeeper.git Add separate serials flag file for flock in gatekeeper The flag file is zero-length and simply exists as a place to use flock. This will eventually allow maintaining a lock while rewriting the serials file using the traditional copy-and-rename method. --- diff --git a/gatekeeper.pl b/gatekeeper.pl index c32e34a..f69470d 100755 --- a/gatekeeper.pl +++ b/gatekeeper.pl @@ -2437,6 +2437,12 @@ sub advance_timestamp_ratchet { my $new_epoch = shift; my $serials_path = File::Spec->catfile(CONF_DIR_State, 'serials'); + my $serials_flag_name = File::Spec->catfile(CONF_DIR_State, 'serials.flag'); + + open my $serials_flag, '>', $serials_flag_name + or die "open serials flag: $!"; + flock $serials_flag, LOCK_EX + or die "lock serials flag: $!"; # Now we need to flock the our 'serials' file; # verify the epoch value there/update it, etc. @@ -2476,6 +2482,8 @@ sub advance_timestamp_ratchet { flock(SERIALS,4); # Release lock close(SERIALS); + flock $serials_flag, LOCK_UN or die "unlock serials flag: $!"; + close $serials_flag or die "close serials flag: $!"; return $old_epoch; }