Drop unused Nginx lock parent arg

This commit is contained in:
Ilia Ross
2026-09-19 01:10:42 +02:00
parent a8a1b70015
commit c134426e2a
2 changed files with 4 additions and 26 deletions

View File

@@ -534,12 +534,11 @@ foreach my $f (@files) {
@open_config_files = ( );
}
# lock_all_config_files([&parent])
# lock_all_config_files()
# Locks all config files and refreshes the config on the outermost call.
# Fetch directive objects after locking; earlier objects may have stale lines.
sub lock_all_config_files
{
my ($parent) = @_;
if ($lock_all_config_files_depth) {
# Nested edits share the caller's config tree and pending changes.
$lock_all_config_files_depth++;
@@ -576,17 +575,15 @@ while (1) {
# An included file may change while this process waits for its lock.
# Reparse after each batch to find any newly included files.
&flush_config_cache();
@files = &unique(&get_all_config_files(),
$parent ? &get_all_config_files($parent) : ());
@files = &get_all_config_files();
}
$lock_all_config_files_depth = 1;
}
# unlock_all_config_files([&parent])
# unlock_all_config_files()
# Un-locks all files used in the current config
sub unlock_all_config_files
{
my ($parent) = @_;
return if (!$lock_all_config_files_depth);
return if (--$lock_all_config_files_depth);
foreach my $f (reverse(@lock_all_config_files_cache)) {

View File

@@ -109,7 +109,7 @@ foreach my $case ([0, 0], [0, 1], [1, 0], [1, 1]) {
main::lock_all_config_files();
my $s = server('beta.invalid');
main::save_directive($s, 'ssl_certificate_key', ['/beta.key']);
main::lock_all_config_files($s);
main::lock_all_config_files();
is(server('beta.invalid'), $s, 'nested lock keeps object identity');
main::unlock_all_config_files();
ok(-e "$conf.lock", 'nested unlock retains main config lock');
@@ -187,23 +187,4 @@ subtest 'included files are refreshed after waiting for their locks' => sub {
main::unlock_all_config_files();
};
subtest 'a parent block can span included files' => sub {
write_text($included, "listen 80;\n");
write_text($conf,
"http {\n".
" server {\n".
" server_name parent.invalid;\n".
" include $included;\n".
" }\n".
"}\n");
main::flush_config_cache();
my $parent = server('parent.invalid');
is_deeply([sort(main::get_all_config_files($parent))],
[sort($conf, $included)], 'parent spans both config files');
main::lock_all_config_files($parent);
ok(-e "$conf.lock" && -e "$included.lock",
'parent lock covers both config files');
main::unlock_all_config_files();
};
done_testing();