Page MenuHomePhabricator

net: keep reference to each node during socket wait
ClosedPublic

Authored by PiRK on Nov 11 2024, 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

Event Timeline

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