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

Close resource manager when host closes #1343

Merged
merged 1 commit into from
Apr 18, 2022

Conversation

gammazero
Copy link
Contributor

When a host is closed, it should close its resource manager. Otherwise, goroutines are leaked.

Generally this is not a problem when a host exists for the life of a program, but can be a problem if hosts are created and closed.

When a host is closed, it should close its resource manager.  Otherwise, goroutines are leaked.

Generally this is not a problem when a host exists for the life of a program, but can be a problem if hosts are created and closed.
Copy link
Contributor

@vyzo vyzo left a comment

Choose a reason for hiding this comment

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

wait,no, there is a reason we havent done this. It is not necessary the case that we own the rcmgr; it could be shared between hosts in the app.

We can only safely close the default instantiation.

cc @marten-seemann

@willscott
Copy link
Contributor

whoops, sorry for the fast approval, i mistakenly thought this PR was up a level in application logic

@vyzo
Copy link
Contributor

vyzo commented Feb 22, 2022 via email

@marten-seemann
Copy link
Contributor

@gammazero Are you planning to fix this PR?

@gammazero
Copy link
Contributor Author

@marten-seemann I will fix it unless you plan to do so this week.

Would you prefer an additional option to tell BasicHost that is should assume ownership of the resource manager, or should BasicHost only close the resource manager if it is the default one?

@marten-seemann
Copy link
Contributor

I'm going to merge this PR. In fact, we have the same problem with the connection manager, and we also close it when the host closes.
This should get solved at some point, but it will probably require a bigger refactor of our host and services.

@marten-seemann marten-seemann merged commit 7a7eb8b into master Apr 18, 2022
gammazero added a commit to ipni/storetheindex that referenced this pull request Jan 18, 2023
It is not necessary to explicitly close a libp2p host's resource manager. The problem was fixed in this PR: libp2p/go-libp2p#1343
gammazero added a commit to ipni/storetheindex that referenced this pull request Jan 18, 2023
* Remove code to resolve address before gostream.Dial

This code is not needed as the problem was fixed by this PR: libp2p/go-libp2p#1342

* No longer necessary to explicitly close resource manager

It is not necessary to explicitly close a libp2p host's resource manager. The problem was fixed in this PR: libp2p/go-libp2p#1343
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants