HomePhabricator

Simplify and fix notifier removal on error.

Description

Simplify and fix notifier removal on error.

Summary:
This factors out the common logic to run over all ZMQ notifiers, call a
function on them, and remove them from the list if the function fails is
extracted to a helper method.

Note that this also fixes a potential memory leak: When a notifier was
removed previously after its callback returned false, it would just be
removed from the list without destructing the object. This is now done
correctly by std::unique_ptr behind the scenes.

This is a backport of core#13686 [2/5]
https://github.com/bitcoin/bitcoin/pull/13686/commits/b93b9d54569145bfcec6cee10968284fe05fe254

Depends on D10282

Test Plan: ninja all check-all

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Differential Revision: https://reviews.bitcoinabc.org/D10283

Details

Provenance
Daniel Kraft <d@domob.eu>Authored on Sep 1 2020, 07:40
PiRKCommitted on Oct 11 2021, 07:01
PiRKPushed on Oct 11 2021, 07:02
Reviewer
Restricted Project
Differential Revision
D10283: Simplify and fix notifier removal on error.
Parents
rABC9d00dd39b534: Various cleanups in zmqnotificationinterface.
Branches
Unknown
Tags
Unknown