Fix infinite loops in connection logic #1694

pull sipa wants to merge 1 commits into bitcoin:master from sipa:fix_netloops changing 2 files +8 −2
  1. sipa commented at 3:38 PM on August 21, 2012: member

    Fix two potential infinite loops in the connection logic:

    • With -noconnect, the -connect code was trigger, but looped infinitely through the empty list of nodes
    • Given restrictions on which networks to connect to, if no such nodes exist in addrman, the code would loop infinitely through the addresses being fetched. Break this loop after 100 iterations.

    Closes #1664.

  2. gavinandresen commented at 3:47 PM on August 21, 2012: contributor

    ACK

  3. BitcoinPullTester commented at 3:08 AM on August 22, 2012: none

    Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/506e17ceb9d09b3914dc3814afe0915a191d0bf4 for binaries and test log.

  4. Diapolo commented at 4:51 AM on August 22, 2012: none

    What happens with your if (nTries > 100), when after that a node occurs in addrman, to which we can connect. Is there a retry timeout or a user feedback somehow?

  5. Fix infinite loops in connection logic f161a2c211
  6. sipa commented at 11:36 AM on August 22, 2012: member

    @Diapolo You're not the first to miss it, so I added a comment to clarify: that break does not stop trying new addresses, it just returns to the outer loop, which sleeps, recalculates allowed address ranges, adds seed nodes, ... before continuing.

  7. gmaxwell commented at 2:15 PM on August 22, 2012: contributor

    ACK. Tests out okay to me.

  8. gmaxwell referenced this in commit a159d6caf0 on Aug 22, 2012
  9. gmaxwell merged this on Aug 22, 2012
  10. gmaxwell closed this on Aug 22, 2012

  11. BitcoinPullTester commented at 11:23 PM on August 22, 2012: none

    Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/f161a2c2114cd7d950248ce75a91ba1923e9abb1 for binaries and test log.

  12. DrahtBot locked this on Sep 8, 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: 2026-04-19 09:16 UTC

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