HomePhabricator

fix: tor: Call event_base_loopbreak from the event's callback

Description

fix: tor: Call event_base_loopbreak from the event's callback

Summary:
PR description:

Calling event_base_loopbreak before event_base_dispatch has no effect. Fix this by calling event_base_loopbreak from the event's callback. From the documentation:

event_base_loop() will abort the loop after the next event is completed; event_base_loopbreak() is typically invoked from this event's callback. This behavior is analogous to the "break;" statement.

The issue was:

When I run
./bitcoind -regtest -whitebind=bla
I expect a clean shutdown with Error: Cannot resolve -whitebind address: 'bla'.
However sometimes my node doesn't stop and freezes (shutdown never finishes).

Backport of Core PR16405

Test Plan:
ninja all check-all

./src/bitcoind -regtest -proxy=127.0.0.1:9050 -listen=1 -bind=127.0.0.1 -whitebind=127.0.0.1:0

After this patch, bitcoind shuts down properly after Error: Cannot resolve -whitebind address: ...

Reviewers: O1 Bitcoin ABC, #bitcoin_abc, Fabien

Reviewed By: O1 Bitcoin ABC, #bitcoin_abc, Fabien

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

Details

Provenance
João Barbosa <joao.paulo.barbosa@gmail.com>Authored on Jul 17 2019, 14:27
PiRKCommitted on Oct 12 2020, 08:59
PiRKPushed on Oct 12 2020, 08:59
Reviewer
Restricted Owners Package
Differential Revision
D7884: fix: tor: Call event_base_loopbreak from the event's callback
Parents
rABC8465ae5d5a5e: Get rid of -Wthread-safety-precise warnings
Branches
Unknown
Tags
Unknown