ThreadOpenConnections bug fix #25783

pull petertodd wants to merge 1 commits into bitcoin:master from petertodd:2022-08-conn-bugfix changing 1 files +1 −1
  1. petertodd commented at 5:12 PM on August 4, 2022: contributor

    Previously would break out of the loop that builds setConnected at the first manual/inbound connection. Replacing break with continue considers the rest of the nodes.

    ...

    At least, that's what I think this does... Not sure what's an easy way to test this, and my C++ is definitely Rusty. :)

  2. ThreadOpenConnections bug fix
    Previously would break out of the loop that builds setConnected at the
    first manual/inbound connection. Replacing break with continue considers
    the rest of the nodes.
    251d9996ef
  3. sipa commented at 5:15 PM on August 4, 2022: member

    The break; breaks out of the switch statement, not out of the loop. I believe changing it to continue; in this case is equivalent, because the end of the loop coincides with the end of the switch statement.

  4. in src/net.cpp:1668 in 251d9996ef
    1664 | @@ -1665,7 +1665,7 @@ void CConnman::ThreadOpenConnections(const std::vector<std::string> connect)
    1665 |                  switch (pnode->m_conn_type) {
    1666 |                      case ConnectionType::INBOUND:
    1667 |                      case ConnectionType::MANUAL:
    1668 | -                        break;
    1669 | +                        continue;
    


    jonatack commented at 5:19 PM on August 4, 2022:

    Unless I'm confused, break here only acts within the scope of the switch statement; it doesn't break out of the for-loop.

  5. petertodd commented at 5:26 PM on August 4, 2022: contributor

    The break; breaks out of the switch statement, not out of the loop. I believe changing it to continue; in this case is equivalent, because the end of the loop coincides with the end of the switch statement.

    Heh, brain fart! Like I said, I haven't actually written C++ code in years; I only work with Rust and Python these days.

  6. petertodd closed this on Aug 4, 2022

  7. petertodd deleted the branch on Aug 4, 2022
  8. bitcoin locked this on Aug 4, 2023

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-17 12:13 UTC

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