http: Improve HTTPRemoteClient::MaybeDisconnect() #36159

pull hodlinator wants to merge 4 commits into bitcoin:master from hodlinator:2026/09/should_disconnect changing 3 files +135 −39
  1. hodlinator commented at 10:41 AM on September 3, 2026: contributor

    Issues

    #35182 had 1 case where we flag a client for disconnect where we do not log the reason.

    #35829 introduced the somewhat poorly named non-const HTTPRemoteClient::MaybeDisconnect(). It also lacks testing.

    The control-flow in MaybeDisconnect()/ShouldDisconnect() is somewhat complex. #35829 (review)

    Commits solving these issues in same order

    • http: Add log message for remaining case where we set HTTPRemoteClient::m_disconnect = true
    • refactor: Rename MaybeDisconnect() to ShouldDisconnect() and make it const
    • test: Add test for behavior of ShouldDisconnect()
    • refactor: Flatten control flow in ShouldDisconnect()
  2. http: Add log message for remaining case where we set m_disconnect = true a7ffe7acba
  3. refactor: Rename MaybeDisconnect() to ShouldDisconnect() and make it const
    Also reins in whitespace while touching the lambda ("Maybe" is one char shorter than "Should" so aligning whitespace would happen anyway).
    b0e7b0cc52
  4. test: Verify behavior of HTTPRemoteClient::ShouldDisconnect()
    Best to nail this down before the refactor in the next commit.
    
    Co-authored-by: JP <jeanpablo.jp@hotmail.com>
    4852498e09
  5. refactor: Flatten control flow in HTTPRemoteClient::ShouldDisconnect()
    Co-authored-by: winterrdog <winterrdog@protonmail.ch>
    332f4e48c5
  6. DrahtBot added the label RPC/REST/ZMQ on Sep 3, 2026
  7. DrahtBot commented at 10:41 AM on September 3, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--006a51241073e994b41acfe9ec718e94-->

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/36159.

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline and AI policy for information on the review process. A summary of reviews will appear here.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

    LLM Linter (✨ experimental)

    Possible places where named args for integral literals may be used (e.g. func(x, /*named_arg=*/0) in C++, and func(x, named_arg=0) in Python):

    • [CreateSock(0, 0, 0)] in src/test/httpserver_tests.cpp

    <sup>2026-09-03 10:41:30</sup>


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-09-04 07:51 UTC

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