Page MenuHomePhabricator

net: keep reference to each node during socket wait
ClosedPublic

Authored by PiRK on Mon, Nov 11, 19:00.

Details

Reviewers
roqqit
Group Reviewers
Restricted Project
Commits
rABC32e377f69f42: net: keep reference to each node during socket wait
Summary

Create the snapshot of CConnman::vNodes to operate on earlier in
CConnman::SocketHandler(), before calling CConnman::SocketEvents()
and pass the vNodes copy from the snapshot to SocketEvents().

This will keep the refcount of each node incremented during
SocketEvents() so that the CNode object is not destroyed before
SocketEvents() has finished.

Currently in SocketEvents() we only remember file descriptor numbers
(when not holding CConnman::cs_vNodes) which is safe, but we will
change this to remember pointers to CNode::m_sock.

This is a partial backport of core#21943
https://github.com/bitcoin/bitcoin/pull/21943/commits/664ac22c5379db65757fc3aab91fff8765683e7f
https://github.com/bitcoin/bitcoin/pull/21943/commits/c7eb19ec8302e6a5abd89c0566540c2c862e9121

Depends on D17106

Test Plan

ninja all check-all

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

PiRK requested review of this revision.Mon, Nov 11, 19:00
PiRK edited the summary of this revision. (Show Details)
PiRK planned changes to this revision.Mon, Nov 11, 19:22
This revision is now accepted and ready to land.Tue, Nov 12, 18:25