libnetdata: make standalone-linkable (#22528)
* libnetdata: register thread-exit cleanups via callbacks Replace the five hard-coded daemon-side cleanup calls in threads.c (rrd_collector_finished, sender_thread_buffer_free, rrdset_thread_rda_free, query_target_free, service_exits) with a register-callback API. The daemon registers its cleanups in rrd_init; libnetdata walks the registered list at thread exit. After this, libnetdata.a no longer carries unresolved references to the five daemon functions. * libnetdata: own all netdata_configured_* globals Move the twelve netdata_configured_* globals (hostname, host_prefix, plus the ten config-path strings) from src/daemon/common.c into a new libnetdata module under src/libnetdata/runtime-paths/. libnetdata owns the storage; the daemon's config layer still writes the values through the extern declarations (now declared once, in libnetdata.h instead of split between libnetdata.h and daemon/common.h). required_dummies.h drops its fallback definitions for these symbols (and for the cleanup functions retired by the sibling commit). The header is kept as a no-op so the ~12 plugins that * libnetdata: remove required_dummies.h The header is no longer needed: libnetdata provides every symbol its consumers used to need local dummies for. Remove the file, the 22 #include lines in plugins / utilities / tests, the entry in CMakeLists.txt, and the stray include in tests/profile/test-eval.c. * libnetdata: move netdata.conf path/hostname loaders into runtime-paths The daemon's two inicfg_get-driven loaders (paths in netdata-conf-directories.c, hostname/host_prefix in netdata-conf-global.c) consisted almost entirely of libnetdata calls operating on libnetdata-owned state. Move them into runtime-paths.c alongside the storage definitions; the daemon wrappers shrink to the orchestration that still needs daemon-specific state (plugin discovery, the FUNCTION_RUN_ONCE guard at each existing entry point). New libnetdata API: void nd_runtime_paths_load_directories_from_inicfg(void); void nd_runtime_paths_load_hostname_from_inicfg(void); Both are idempotent and safe to call multiple times. The daemon's public function names (netdata_conf_section_directories, netdata_conf_section_global_hostname) are unchanged; the 11 existing callers of the former and the 1 caller of the latter need no changes. * libnetdata: initialize cleanup-registry spinlock with SPINLOCK_INITIALIZER Using `{ 0 }` happens to work for the bool-backed spinlock but bypasses the contract on SPINLOCK_IMPL_WITH_MUTEX builds, where the macro expands to `{ .inner = PTHREAD_MUTEX_INITIALIZER }`. * Properly initialize buf. Initialize buf before os_hostname() so the fallback passed to inicfg_get() is always a valid string when hostname lookup fails. Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com> --------- Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>