| ... |
... |
@@ -245,16 +245,35 @@ sub confkey_str { |
|
245
|
245
|
ref $_[0] eq 'ARRAY' ? join '/', @{$_[0]} : $_[0];
|
|
246
|
246
|
}
|
|
247
|
247
|
|
|
|
248
|
+sub error_many_lookups {
|
|
|
249
|
+ my ($project, $name_str, $lookups_count) = @_;
|
|
|
250
|
+ my $errmsg = "High number of config lookups for option $name_str" .
|
|
|
251
|
+ " in project $project.\n" .
|
|
|
252
|
+ "This may indicate a loop in the definition of $name_str.\n\n" .
|
|
|
253
|
+ "Most requested options, possibly part of the loop, are:\n";
|
|
|
254
|
+ my @opts = sort {
|
|
|
255
|
+ $lookups_count->{$b} cmp $lookups_count->{$a}
|
|
|
256
|
+ } keys %$lookups_count;
|
|
|
257
|
+ foreach my $opt (@opts[0 .. 9]) {
|
|
|
258
|
+ last unless $lookups_count->{$opt};
|
|
|
259
|
+ $errmsg .= " - $opt ($lookups_count->{$opt})\n";
|
|
|
260
|
+ }
|
|
|
261
|
+ exit_error($errmsg);
|
|
|
262
|
+}
|
|
|
263
|
+
|
|
248
|
264
|
sub project_config {
|
|
249
|
265
|
my ($project, $name, $options) = @_;
|
|
250
|
266
|
$used_projects{$project} = 1 if $store_used_projects;
|
|
251
|
267
|
CORE::state %config_cache;
|
|
|
268
|
+ CORE::state %lookups_count;
|
|
252
|
269
|
my $res;
|
|
253
|
270
|
my $error_if_undef = $options->{error_if_undef};
|
|
254
|
271
|
$options = {%$options, error_if_undef => 0} if $options;
|
|
255
|
272
|
my $cache_id = pp($config->{run})
|
|
256
|
273
|
. pp({ %{$config->{opt}}, $options ? %$options : () });
|
|
257
|
274
|
my $name_str = ref $name eq 'ARRAY' ? join '/', @$name : $name;
|
|
|
275
|
+ error_many_lookups($project, $name_str, $lookups_count{$project})
|
|
|
276
|
+ if (++$lookups_count{$project}{$name_str} > 500);
|
|
258
|
277
|
my $step = $config->{step};
|
|
259
|
278
|
if (exists $config_cache{$project}{$step}{$name_str}{$cache_id}) {
|
|
260
|
279
|
$res = $config_cache{$project}{$step}{$name_str}{$cache_id};
|
| ... |
... |
@@ -290,6 +309,7 @@ sub project_config { |
|
290
|
309
|
$config_cache{$project}{$step}{$name_str}{$cache_id} = $res;
|
|
291
|
310
|
$config->{opt} = $opt_save;
|
|
292
|
311
|
FINISH:
|
|
|
312
|
+ --$lookups_count{$project}{$name_str};
|
|
293
|
313
|
if (!defined($res) && $error_if_undef) {
|
|
294
|
314
|
my $msg = $error_if_undef eq '1' ?
|
|
295
|
315
|
"Option " . confkey_str($name) . " is undefined"
|