bitcoin/bitcoin — pull request #947 by ali1234 (2012-03-18 03:09:01+00:00)
Title: When disconnecting a node, the receive buffer should be cleared

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.