fix: tor: Call event_base_loopbreak from the event’s callback #16405

pull promag wants to merge 1 commits into bitcoin:master from promag:2019-07-fix-break-before-dispatch changing 1 files +3 −1
  1. promag commented at 2:33 pm on July 17, 2019: member

    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.

    This can be tested by running the following with and without this change:

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

    Fixes #16376.

  2. fix: tor: Call event_base_loopbreak from the event's callback a981e749e6
  3. promag commented at 2:36 pm on July 17, 2019: member
    To backport.
  4. laanwj commented at 2:59 pm on July 17, 2019: member
    Yes, this seems the most straightforward solution. code review ACK a981e749e6553487cd48eda28e590f769e81c85c
  5. promag referenced this in commit b2711b98bd on Jul 17, 2019
  6. DrahtBot added the label P2P on Jul 17, 2019
  7. fanquake approved
  8. fanquake commented at 2:48 am on July 18, 2019: member

    ACK a981e749e6553487cd48eda28e590f769e81c85c

    Tested that the change fixes the hanging behavior at shutdown using the above command.

    In regards to the code. If I understand correctly we are calling event_base_once to trigger a one-time event, and by passing EV_TIMEOUT as events, and nullptr to timeout, this causes the callback to be executed immediately. The callback calls event_base_loopbreak and that will:

    Abort the active event_base_loop() immediately."

    This is required because we haven’t yet called event_base_dispatch, which would be done just after this code.

  9. promag commented at 7:56 am on July 18, 2019: member

    to be executed immediately

    to be queued and called asap by the event base.

  10. laanwj merged this on Jul 18, 2019
  11. laanwj closed this on Jul 18, 2019

  12. laanwj referenced this in commit 65d12110d4 on Jul 18, 2019
  13. fanquake referenced this in commit 3f76160087 on Jul 18, 2019
  14. promag deleted the branch on Jul 18, 2019
  15. HashUnlimited referenced this in commit d03543523d on Aug 23, 2019
  16. Bushstar referenced this in commit d9b725d056 on Aug 24, 2019
  17. Bushstar referenced this in commit 0c01e43939 on Aug 24, 2019
  18. Bushstar referenced this in commit 7ddb11671c on Aug 24, 2019
  19. Bushstar referenced this in commit 1f6d4dfd95 on Aug 24, 2019
  20. jasonbcox referenced this in commit 3f706f09ac on Oct 12, 2020
  21. PastaPastaPasta referenced this in commit 9cc8ebed8a on Jun 27, 2021
  22. PastaPastaPasta referenced this in commit 59d599fb5b on Jun 28, 2021
  23. PastaPastaPasta referenced this in commit 643bae5bd3 on Jun 29, 2021
  24. PastaPastaPasta referenced this in commit 008b7889e8 on Jul 1, 2021
  25. PastaPastaPasta referenced this in commit eba7908278 on Jul 1, 2021
  26. PastaPastaPasta referenced this in commit d47f4f9b2a on Jul 12, 2021
  27. PastaPastaPasta referenced this in commit f2bb2844a0 on Jul 13, 2021
  28. DrahtBot locked this on Dec 16, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-07-05 22:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me