Do not kill connections on recv buffer overflow #2599

pull sipa wants to merge 1 commits into bitcoin:master from sipa:norecvdisc changing 1 files +30 −15
  1. sipa commented at 4:47 PM on April 30, 2013: member

    Instead of killing a connection when the receive buffer overflows, just temporarily halt receiving before that happens. Also, no matter what, always allow at least one full message in the receive buffer (otherwise blocks larger than the configured buffer size would pause indefinitely).

    Fixes #2597.

  2. sipa commented at 4:47 PM on April 30, 2013: member

    Tested with -maxreceivebuffer=3 (yes, that means 3 kilobytes).

  3. jgarzik commented at 5:18 PM on April 30, 2013: contributor

    It seems like this creates a remotely trigger-able state, whereby someone would not be selected for read or write, yet the socket and CNode would remain, using system resources.

  4. sipa commented at 5:22 PM on April 30, 2013: member

    @jgarzik How so? There is always progress:

    • Because there is a message in the send buffer left (so we send)
    • or there is no complete message in the receive buffer (so we receive)
    • or there is a complete message in the receive buffer (so we process)
  5. sipa commented at 6:51 PM on May 1, 2013: member

    It seems the current code actually has a minor bug, as it means not setting have_fds / hSocketMax if the lock on cs_vSend cannot be acquired.

    I restructured the flow a bit, so now send and recv locks are both tried separately, and only as long as necessary.

    I also added some comment explaining the reasoning and why it cannot cause a deadlock.

  6. Do not kill connections on recv buffer overflow
    Instead of killing a connection when the receive buffer overflows,
    just temporarily halt receiving before that happens. Also, no
    matter what, always allow at least one full message in the receive
    buffer (otherwise blocks larger than the configured buffer size
    would pause indefinitely).
    a9d9f0f5f7
  7. BitcoinPullTester commented at 7:38 PM on May 1, 2013: none

    Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/a9d9f0f5f72ab1f9ebc2f76bfe3b7921fa2826d7 for binaries and test log. This test script verifies pulls every time they are updated. It, however, dies sometimes and fails to test properly. If you are waiting on a test, please check timestamps to verify that the test.log is moving at http://jenkins.bluematt.me/pull-tester/current/ Contact BlueMatt on freenode if something looks broken.

  8. sipa commented at 7:06 PM on May 2, 2013: member

    @jgarzik Mind taking another look at this?

  9. gmaxwell commented at 8:58 PM on May 2, 2013: contributor

    ACK.

  10. laanwj commented at 9:42 PM on May 3, 2013: member

    ACK (code looks ok, and tested downloading the testnet block chain using a very small receive buffer)

  11. jgarzik commented at 10:11 PM on May 3, 2013: contributor

    ACK

  12. sipa referenced this in commit 979a22a7a0 on May 3, 2013
  13. sipa merged this on May 3, 2013
  14. sipa closed this on May 3, 2013

  15. sipa deleted the branch on May 3, 2013
  16. laudney referenced this in commit f7e8ee084e on Mar 19, 2014
  17. pyritepirate referenced this in commit 0244e616b4 on Jan 23, 2019
  18. 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:15 UTC

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