When disconnecting a node, the receive buffer should be cleared #947

pull ali1234 wants to merge 1 commits into bitcoin:master from ali1234:master changing 1 files +1 −0
  1. ali1234 commented at 3:09 AM on March 18, 2012: contributor

    Currently, if a node is banned for misbehaviour the receive buffer, vRecv, is not cleared and ProcessMessages continues to process any further messages already received from the node.

    Thus, if a node spams hundreds of messages and does not wait for a response, all the messages get processed, even if the node is banned after just a couple.

    This patch clears the receive buffer when the socket is closed. Perhaps it should be done in Misbehaving() instead? But it seems logical that we never want to process messages from a disconnected node since we can't reply to them anyway.

    EDIT: Two things I forgot to mention:

    Firstly, I found this problem in litecoin, which is being actively attacked by spammers. I don't know for sure if bitcoin has this problem.

    Secondly, this won't do much alone, because there is very little code to actually ban bad nodes. I am experimenting with detecting bad behaviour - ie adding banning code, and that's how I noticed this.

  2. When disconnecting a node, clear the received buffer so that we do
    not process any already received messages.
    
    The primary reason to do this is if a node spams hundreds of messages
    and we ban them, we don't want to continue processing the rest of it.
    bb13d056ea
  3. gavinandresen commented at 2:33 PM on March 19, 2012: contributor

    ACK

  4. gavinandresen referenced this in commit 2e2c04e250 on Mar 21, 2012
  5. gavinandresen merged this on Mar 21, 2012
  6. gavinandresen closed this on Mar 21, 2012

  7. coblee referenced this in commit c530c391f0 on Jul 17, 2012
  8. suprnurd referenced this in commit 1ecabea8a6 on Dec 5, 2017
  9. ptschip referenced this in commit af255b75d3 on Jan 27, 2018
  10. lateminer referenced this in commit 6ce55eec2d on Oct 30, 2019
  11. sipa referenced this in commit c020cbaa5c on Jul 14, 2021
  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-14 21:15 UTC

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