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