They were only used in places where they really should not have been used.
Replaces #10697.
They were only used in places where they really should not have been used.
Replaces #10697.
152@@ -153,6 +153,8 @@ struct CBlockReject {
153 * and we're no longer holding the node's locks.
154 */
155 struct CNodeState {
156+ //! The CConnman reference to the connection
157+ CNode* connection;
Concept ACK.
Are all changes required to remove ForNode
and ForEachNode
?
Strong concept ACK
Getting this merged will allow removing this ugly -Wthread-safety
work-around: https://github.com/bitcoin/bitcoin/pull/11226/commits/5a890d376f7a296a6a4a7ce0d076012ef920b239
127+static void pop_lock(void* cs)
128 {
129+ // We assert here that locks are popped in the order they were locked.
130+ // This is a super-overly-restrictive requirement, but we need it to
131+ // make our deadlock detection work properly.
132+ assert((*lockstack).back().first == cs);
If I’m understanding this correctly, I think it may cause issues with recursive locks that are currently harmless (though potentially troublesome)? e.g.:
0recursive_mutex a;
1recursive_mutex b;
2lock(a)
3lock(a)
4lock(b)
5lock(b)
6unlock(a)
7unlock(b)
8unlock(b)
9unlock(a)
Yes, those will now be DEBUG_LOCKORDER failures, but it appears to currently not be violated, and would detect some potentially significant issues, consider:
lock(a) lock(b) unlock(a) (this now pops b off the stack, so lockorder thinks we have a locked) lock(a) (this is a deadlock cause we’ve now violated lockorder, but DEBUG_LOCKORDER thinks that we’re just re-locking a).
239@@ -238,7 +240,7 @@ struct CNodeState {
240 //! Time of last new block announcement
241 int64_t m_last_block_announcement;
242
243- CNodeState(CAddress addrIn, std::string addrNameIn) : address(addrIn), name(addrNameIn) {
244+ CNodeState(CNode* connectionIn) : connection(connectionIn), address(connection->addr), name(connection->GetAddrName()) {
This really clashes with the libevent work, which totally reworks the disconnection logic.
Can we revisit this down the road a bit? It’s a bit frustrating to have some of these things already worked out, but stuck waiting on per-requisite PR review.
That said, concept ACK on moving RelayTransaction/nStartingHeight out of net.
How does this conflict with libevent? The disconnect logic is still based on telling CConnman to do X with a peer, no? And FinalizeNode being moved around shouldn’t matter too much, just as long as its not called at the same time as a call to one of the other NetEventsInterface calls.
This is a rather simple PR, I’m happy to rebase it on some different disconnect-order tweaks that are pulled out of libevent (I assume you’re gonna reorg them prior to pulling in the whole libevent reword as a separate thing) but it’d be a shame for a fix like this which mostly just pulls net and net_processing apart further to wait on a major rework of net.
913+ for (auto& node : mapNodeState) {
914+ CNodeState& nodestate = node.second;
915+ if (nNewHeight > (nodestate.nStartingHeight != -1 ? nodestate.nStartingHeight - 2000 : 0)) {
916 for (const uint256& hash : reverse_iterate(vHashes)) {
917- pnode->PushBlockHash(hash);
918+ nodestate.connection->PushBlockHash(hash);
This prevents any CNode refcount entries outside of net from
blocking CNode deletion.
The CNode/CNodeState terminology is rather outdated now - CNode
should be considered representative of the connection for the
purposes of telling CConnman where to send data, so giving
CNodeState a reference to it makes perfect sense. This also allows
us to migrate off of CConnman's ForEachNode/ForNode
It is a "protocol-level-logic" field, and thus belongs in
net_processing and not in net.
This is very clearly a "protocol-level" action, so belongs in
net_processing, not net.
Again, queueing pings is very much "protocol-level" logic, and
belongs in net_processing, not net.
TheBlueMatt
promag
practicalswift
theuni
Labels
P2P