2 suggestions
Optional improvements
[suggestion] · Signal destruction during emission lacks test coverage
Tests do not cover signal destruction from a callback, which now skips later callbacks while preserving the active callable; no current caller exercising this trigger was found.
Location: src/util/btcsignals.h:228 (head).
Details and suggested fix
operator() snapshots the holders before invoking callbacks and does not access signal members afterward. If a callback destroys the signal, the new destructor clears every holder's callback, so later snapshot entries are skipped. The active callable remains alive through its local shared_ptr. At base, the defaulted destructor left snapshot-owned callbacks available, so later callbacks still ran. This change matches the existing disconnection semantics, but the added test destroys only an idle signal. Add a case where callback A resets the std::unique_ptr<btcsignals::signal<void()>> owning the signal and callback B sets a flag. Check that B does not run, that A's captured state remains alive after the reset, and that it is released when the invocation returns.
[suggestion] · Signal-destruction test covers only one connection
The new callback_destruction block cannot distinguish disconnecting every entry from disconnecting only the first or last entry.
Location: src/test/btcsignals_tests.cpp:127 (head).
Details and suggested fix
The sig2 fixture retains one handle and checks one captured state's expiration after signal destruction. A destructor that disconnected only m_connections.front() or m_connections.back() would satisfy both assertions. Existing multi-entry tests check emission or explicit disconnection while the signal is alive, not the state after its destruction. Extend this block with two callbacks owning separate captured state and retain both handles outside the scope. Then check that both weak_ptrs expire and both handles report !connected(). Including an already-disconnected entry would also check that teardown continues past it.
Background
Ralph's summary of historical context for the behaviour affected by this change. The historical record reviewed here is incomplete.
Documented decisions
Eager callback release was intended to provide predictable resource lifetimes, not merely to prevent future invocation. The preceding fix reported that retained callbacks owned mp::EventLoopRef references and prevented node shutdown after GUI callbacks were disconnected.
The destructor change affects the same ownership boundary: a callback that cannot usefully receive further signal emissions can still retain shutdown-critical captured state. This explains why releasing the callable matters independently of the connection's reported status.
Keeping disconnected bookkeeping entries until a later connect() was a deliberate simplicity tradeoff. The preceding fix rejected a callback deleter that reached back into the signal because handles can survive it, the last release can occur on an emitting or destructor thread, and removing entries would require additional lifetime machinery and locking.
The intended separation is between promptly releasing user-owned callable state and lazily collecting small connection entries. The head destructor uses the existing disconnect operation rather than making surviving handles depend on a live signal.