Skip to content

Conversation

@Sjors
Copy link
Member

@Sjors Sjors commented Sep 25, 2024

Based on post-merge comments on #30409.

Sjors and others added 3 commits September 25, 2024 09:49
An earlier version of this code was written to handle the case where now + timeout calculation would overflow, basically assuming both values were unsigned integer values and overflow behavior would be well defined.

But since timeout is a floating point number where "overflow" would just result in inf being set, trying to deal with it this way doesn't make sense.

Co-authored-by:  Ryan Ofsky <ryan@ofsky.org>
This will print a more usable error message. EnsureAnyNodeContext is intended for RPC method implementations.

Co-authored-by: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz>
@DrahtBot
Copy link
Contributor

DrahtBot commented Sep 25, 2024

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Code Coverage

For detailed information about the code coverage, see the test coverage report.

Reviews

See the guideline for information on the review process.
A summary of reviews will appear here.

@Sjors
Copy link
Member Author

Sjors commented Sep 25, 2024

@theuni also wrote:

Related: It's a shame that the condvar/mutex leak out of here. Is there a reason not to add getter/waiter/notifier functions?

Not sure how to go about that, but happy to take a patch.

Copy link
Member

@maflcko maflcko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've opened #30967, which includes the follow-ups here, but I solved them in another way.

Feel free to take or leave them. I can drop them from mine, once this one is merged.

// validation chain.
BOOST_CHECK(block_added);
BOOST_CHECK_EQUAL(curr_tip, m_node.notifications->m_tip_block);
new_tip = WITH_LOCK(m_node.notifications->m_tip_block_mutex, return m_node.notifications->m_tip_block;);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems verbose to lock this every time. Also, the comment above is still wrong. It would be good to drop this commit, or replace it with fa7dd1d072dc36997e2d5d702e2da529a093c90f, which also fixes up the outdated comment.

WITH_LOCK(g_deadline_timers_mutex, deadlineTimers.clear());
DeleteAuthCookie();
node::NodeContext& node = EnsureAnyNodeContext(context);
node::NodeContext& node = *Assert(util::AnyPtr<node::NodeContext>(context));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems overly complicated to turn a reference into a pointer, then turn it into std::any, then recover it from any, then assert the pointer isn't null.

It would be better to remove all of this and just pass the reference.

So it would be good to drop this commit or replace it with fadd531a57710809df0e4b027ce30b5524e5f40f, which does the above.

@Sjors
Copy link
Member Author

Sjors commented Sep 25, 2024

Let's go with #30967.

@Sjors Sjors closed this Sep 25, 2024
@bitcoin bitcoin locked and limited conversation to collaborators Sep 25, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants