mirror of
http://thekelleys.org.uk/git/dnsmasq.git
synced 2026-10-18 11:09:36 +00:00
a9cb3971c695e0132f52a225b80c604ed47864f3
When reloading large hosts files (e.g. 1.7M addn-hosts entries) on SIGHUP, free_names() previously only reset block->last = 0 without unlinking or moving blocks to a spare pool. As a result, all existing blocks remained in hostblocks. When reloading, the head block was filled first and stayed at the head while full, forcing store_name() to linearly traverse all previously filled blocks for every subsequent name insertion. This resulted in O(N^2) complexity, taking ~10 minutes for 1.7M records. Fix this by introducing nameblock_spare (matching config_spare / big_free spare pool semantics), moving freed blocks to the spare pool in free_names(), and restricting store_name() to only check the active head block before popping from nameblock_spare (or mallocing). This restores O(1) per-entry insertion and reduces reload time from 10 minutes to ~3 seconds.
Languages
C
94.3%
Perl
2.2%
HTML
1.2%
Shell
1%
Makefile
0.6%
Other
0.6%