HomePhabricator

[net processing] Reduce cs_main scope in MaybeDiscourageAndDisconnect()

Description

[net processing] Reduce cs_main scope in MaybeDiscourageAndDisconnect()

Summary:

The motivation for this PR is to reduce the scope of cs_main locking in
misbehavior logic. It is the first set of commits from a larger branch
to move the misbehavior data out of CNodeState and into a new struct
that doesn't take cs_main.

There are some very minor behavior changes in this branch, such as:

    Not checking for discouragement/disconnect in ProcessMessages() (and
instead relying on the following check in SendMessages())
    Checking for discouragement/disconnect as the first action in
SendMessages() (and not doing ping message sending first)
    Continuing through SendMessages() if MaybeDiscourageAndDisconnect()
doesn't disconnect the peer (rather than dropping out of SendMessages()

Backport of core PR19472.

Depends on D8782 and D8791.

Test Plan:
With Clang and debug:

ninja all check-all

./contrib/teamcity/build-configurations.py build-tsan

Reviewers: #bitcoin_abc, majcosta

Reviewed By: #bitcoin_abc, majcosta

Subscribers: majcosta

Differential Revision: https://reviews.bitcoinabc.org/D8792

Details

Provenance
John Newbery <john@johnnewbery.com>Authored on Jun 15 2020, 14:15
FabienCommitted on Jan 6 2021, 10:47
FabienPushed on Jan 6 2021, 10:49
Reviewer
Restricted Project
Differential Revision
D8792: [net processing] Reduce cs_main scope in MaybeDiscourageAndDisconnect()
Parents
rABC6176f87a9d44: Rename CheckIfBanned() to MaybeDiscourageAndDisconnect()
Branches
Unknown
Tags
Unknown