Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(upnp): do not return failure events repeatedly #4569

Merged
merged 4 commits into from
Sep 28, 2023

Conversation

arpankapoor
Copy link
Contributor

@arpankapoor arpankapoor commented Sep 28, 2023

Description

When a gateway is not found or is not routable, UPnP NetworkBehaviour's poll repeatedly returns the same failure state, which increases CPU usage.

Notes & open questions

I've modified the ping example to demostrate the issue. You can see the difference in cpu usage when cargo running this example with and without the change. I'll revert the example changes and add a changelog entry if the change seems ok.

Change checklist

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • A changelog entry has been made in the appropriate crates

Copy link
Contributor

@thomaseizinger thomaseizinger left a comment

Choose a reason for hiding this comment

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

Good catch!

Just two comments :)

protocols/upnp/src/behaviour.rs Show resolved Hide resolved
examples/ping/src/main.rs Outdated Show resolved Hide resolved
@thomaseizinger thomaseizinger changed the title perf(upnp): do not return failure events repeatedly fix(upnp): do not return failure events repeatedly Sep 28, 2023
@thomaseizinger thomaseizinger mentioned this pull request Sep 28, 2023
@thomaseizinger
Copy link
Contributor

Thanks!

Copy link
Member

@mxinden mxinden left a comment

Choose a reason for hiding this comment

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

Makes sense to me.

Tagging @jxs here as well for visibility.

@mergify mergify bot merged commit d30eb9d into libp2p:master Sep 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants