HomePhabricator

Merge #17251: net: SocketHandler logs peer id for close and disconnect

Description

Merge #17251: net: SocketHandler logs peer id for close and disconnect

Summary:
04dbdd613fe5c0a742de915e07553614cd4cbf46 [net] SocketHandler: log peer id for close and disconnect (Sjors Provoost)

Pull request description:

When combined with `-logips` this makes it easier to diagnose disconnects.

To test on macOS, find a connection you want to disrupt:

```
lsof -nP -iTCP:8333 -sTCP:ESTABLISHED
```

To shut it down gracefully you can use tcpkill or this Python script: https://github.com/google/tcp_killer

The log should say:

```
2019-10-25T13:26:55Z socket closed for peer=1
2019-10-25T13:26:55Z disconnecting peer=1
2019-10-25T13:26:55Z Cleared nodestate for peer=1
```

To shut it down ungracefully I made a patch to the above script, adding a `-force` argument. _Careful, this may result in data corruption_. Then the log should say:

```
2019-10-25T13:39:57Z socket select error Bad file descriptor (9)
2019-10-25T13:39:57Z socket recv error for peer=0: Bad file descriptor (9)
2019-10-25T13:39:57Z disconnecting peer=0
2019-10-25T13:39:57Z Socket close failed: 35. Error: Bad file descriptor (9)
2019-10-25T13:39:57Z Cleared nodestate for peer=0
```

Backport of Core PR17251

Test Plan: ninja check check-functional

Reviewers: #bitcoin_abc, deadalnix

Reviewed By: #bitcoin_abc, deadalnix

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

Details

Provenance
fanquake <fanquake@gmail.com>Authored on Oct 14 2020, 22:07
jasonbcoxCommitted on Oct 14 2020, 22:07
abc-botPushed on Oct 14 2020, 22:13
Reviewer
Restricted Project
Differential Revision
D7921: Merge #17251: net: SocketHandler logs peer id for close and disconnect
Parents
rABC2ddf834cf13b: [CI] Add required packages for building and uploading a DEB file
Branches
Unknown
Tags
Unknown