files: Warn once for missing get_file_handle()

Repeating the message for every new call to get_file_handle() is not
very useful. It's pretty much an analyzer configuration issue so logging
it once should be enough.
This commit is contained in:
Arne Welzel 2023-05-15 13:45:44 +02:00 committed by Tim Wojtulewicz
parent 9bda48d17c
commit d4c99e7c3f
3 changed files with 67 additions and 2 deletions

View file

@ -510,11 +510,19 @@ function describe(f: fa_file): string
return handler$describe(f);
}
# Only warn once about un-registered get_file_handle()
global missing_get_file_handle_warned: table[Files::Tag] of bool &default=F;
event get_file_handle(tag: Files::Tag, c: connection, is_orig: bool) &priority=5
{
if ( tag !in registered_protocols )
{
Reporter::warning(fmt("get_file_handle() invoked for %s", tag));
if ( ! missing_get_file_handle_warned[tag] )
{
missing_get_file_handle_warned[tag] = T;
Reporter::warning(fmt("get_file_handle() handler missing for %s", tag));
}
set_file_handle(fmt("%s-fallback-%s-%s-%s", tag, c$uid, is_orig, network_time()));
return;
}