Skip to content

Commit 65d1211

Browse files
committed
Merge #16405: fix: tor: Call event_base_loopbreak from the event's callback
a981e74 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 ACK a981e74 fanquake: ACK a981e74 Tree-SHA512: 328fe71366404d5be8177d7081d5b4868cee73412df631a1865d24fb1c153427210762738109e06b737f037f4c68966812fba041831bb9e8129861f19ce61a63
2 parents 0515406 + a981e74 commit 65d1211

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/torcontrol.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,9 @@ void InterruptTorControl()
759759
{
760760
if (gBase) {
761761
LogPrintf("tor: Thread interrupt\n");
762-
event_base_loopbreak(gBase);
762+
event_base_once(gBase, -1, EV_TIMEOUT, [](evutil_socket_t, short, void*) {
763+
event_base_loopbreak(gBase);
764+
}, nullptr, nullptr);
763765
}
764766
}
765767

0 commit comments

Comments
 (0)