Merge #16405: fix: tor: Call event_base_loopbreak from the event's callback
a981e749e6
fix: tor: Call event_base_loopbreak from the event's callback (João Barbosa) Pull request 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](http://www.wangafu.net/~nickm/libevent-2.0/doxygen/html/event_8h.html#a07a7599e478e4031fa8cf52e26d8aa1e): > 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. This can be tested by running the following with and without this change: ```sh bitcoind -- -regtest -proxy=127.0.0.1:9050 -listen=1 -bind=127.0.0.1 -whitebind=127.0.0.1:0 ``` Fixes #16376. ACKs for top commit: laanwj: code review ACKa981e749e6
fanquake: ACKa981e749e6
Tree-SHA512: 328fe71366404d5be8177d7081d5b4868cee73412df631a1865d24fb1c153427210762738109e06b737f037f4c68966812fba041831bb9e8129861f19ce61a63
This commit is contained in:
commit
65d12110d4
1 changed files with 3 additions and 1 deletions
|
@ -759,7 +759,9 @@ void InterruptTorControl()
|
|||
{
|
||||
if (gBase) {
|
||||
LogPrintf("tor: Thread interrupt\n");
|
||||
event_base_loopbreak(gBase);
|
||||
event_base_once(gBase, -1, EV_TIMEOUT, [](evutil_socket_t, short, void*) {
|
||||
event_base_loopbreak(gBase);
|
||||
}, nullptr, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue