WIP: dns: Fix Boost serialization singleton assertion error during shutdown
TODO: This needs very careful review, it's written by AI.
The test_dns test was crashing with:
Assertion '! is_destroyed()' failed in Boost serialization singleton
Root cause: The static const string DnsCache::DoNotUseCacheFile was being
destroyed during program shutdown before the global fixture's destructor ran.
This caused string comparisons to compare with corrupted memory, leading to
incorrect branch execution and archive operations during program exit.
Fixes:
- Add UseCacheFile boolean flag set in constructor, used instead of comparing
CacheFile against DoNotUseCacheFile to avoid string comparison during shutdown
- Set InShutdown flag at the very start of destructor before any other operations
- Skip scheduling save timer for caches that don't use a file
- Use ForceSave flag to allow saving from destructor even when InShutdown is true
- Add proper shutdown checks in remove_old_entries() to skip unnecessary work
- Fix test fixture destruction order to reset Cache and Master before IoService