diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2019-07-18 13:24:51 +0200 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2019-07-18 13:58:12 +0200 |
commit | 65d12110d43ac89bc0320477bfea6b375fc2134b (patch) | |
tree | 505c2d2609b7c19fe173ccd08214c1b284beb6d9 | |
parent | 0515406acb5d0c60e743822853b80e122285a82c (diff) | |
parent | a981e749e6553487cd48eda28e590f769e81c85c (diff) |
Merge #16405: fix: tor: Call event_base_loopbreak from the event's callback
a981e749e6553487cd48eda28e590f769e81c85c 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 a981e749e6553487cd48eda28e590f769e81c85c
fanquake:
ACK a981e749e6553487cd48eda28e590f769e81c85c
Tree-SHA512: 328fe71366404d5be8177d7081d5b4868cee73412df631a1865d24fb1c153427210762738109e06b737f037f4c68966812fba041831bb9e8129861f19ce61a63
-rw-r--r-- | src/torcontrol.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/torcontrol.cpp b/src/torcontrol.cpp index a1c730ba08..3f40785c21 100644 --- a/src/torcontrol.cpp +++ b/src/torcontrol.cpp @@ -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); } } |