Root cause:
handle_instance_without_section() returned empty in BROWSE_FIND_MAX_INST,
so dynamic (UPnP) rules weren’t counted and new static rules reused indices.
Fix:
also allocate/return the instance in FIND_MAX so dynamic instances contribute
to max_instance and indices remain consistent.
Added an exclusive file locking mechanism using `flock()` to ensure that
only one process at a time can update the '/var/state/bbfdm_reference_db' file.
This prevents data loss or corruption caused by concurrent access.
This change improves robustness when `bbfdm_refresh_references()` is called
by multiple processes in parallel.