Alan T. DeKok [Sun, 4 Feb 2024 15:15:35 +0000 (10:15 -0500)]
clean up autofree
The only remaining errors are:
test.unit.dns, which fails to clean up the DNS dictionaries.
All of the other protocols are fine, so there's some extra magic
here.
test.keywords: fr_dict_free() is asked to remove a dependency
which doesn't exist. That _should_ be an assertion, but for now
it's a recoverable error which lets other people get work done.
Alan T. DeKok [Sat, 3 Feb 2024 20:47:21 +0000 (15:47 -0500)]
Move to init/free for library, and not for each test case
now that we (mostly) have library-based init/free, we do not need
to do that for every test case. Either the library is properly
initialized and it works, or the library isn't initialized, and
the tests fail.
Some protocols still need to be converted to use fr_dict_protocol_t
Alan T. DeKok [Sat, 3 Feb 2024 14:05:14 +0000 (09:05 -0500)]
allow for loops in foreign dictionaries
by adding two flags, "loading", which is set in begin-proto,
and cleared when the dictionary is done. And "loaded" which is
set by fr_protocol_afrom_file(), to indicate that it has loaded
the dictionary file. and initialized the protocol library.
The dict routines now call proto->init() and proto->free(), so that
when a protocol library is loaded, everything it needs is also
loaded and initialized.
Alan T. DeKok [Sat, 3 Feb 2024 14:04:08 +0000 (09:04 -0500)]
remove internal dictionary last.
Many protocol dictionaries reference it. If we try to remove it
first, it will still be referenced by them. Instead, we want to
remove the protocol dictionaries first, and only then remove the
internal dictionary.
James Jones [Mon, 29 Jan 2024 20:28:05 +0000 (14:28 -0600)]
Attempt to placate Coverity in rs_packet_process() (CID #1587345)
Coverity infers from the check of original->expect in the call to
fr_radius_decode_simple() that original->expect can be NULL, and
hence the later call to rs_stats_update_latency() call that
dereferences original->expect may fail. It may be that if original
and original->linked are non-NULL, one can infer original->expect
is non-NULL. Coverity can't; hence the added check on that call to
rs_stats_update_latency()..
Alan T. DeKok [Wed, 31 Jan 2024 15:20:19 +0000 (10:20 -0500)]
call _exit() when checking if a debugger is attached.
Callng exit() not only calls all of the atexit() handlers,
which we don't need for a temporary, throw-away child process,
it also causes many pages to be written to unnecessarily. Which
causes them to be cloned (due to copy on write), and then the
pages are immediately thrown away.
Alan T. DeKok [Wed, 31 Jan 2024 14:06:31 +0000 (09:06 -0500)]
delay reading dictionaries until after setting up debug state
On Linux, fr_get_debug_state() calls fork() to get debugging
status. It then calls exit(), which calls the atexit() handlers,
which complain that memory isn't cleaned up.
We hoist those checks to above the "read dictionary" call, so that
the atexit() handlers won't trigger.
Alan T. DeKok [Tue, 30 Jan 2024 21:03:43 +0000 (16:03 -0500)]
add and use TEST_FINI for acutest
so that the dictionaries are cleaned up when we exit.
This commit also removes the use of constructors. While this
change makes the tests slower, we do need everything to be cleaned
up on exit, to avoid errors
Alan T. DeKok [Mon, 29 Jan 2024 13:50:52 +0000 (08:50 -0500)]
more checks on init / free
on init, we increment the ref count _before_ autoloading the
dictionaries. That way if the function is called recursively,
(as when dictionaries reference each other), nothing is done.