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

Cleanup resources #246

Merged
merged 16 commits into from
Jun 29, 2020
Merged

Cleanup resources #246

merged 16 commits into from
Jun 29, 2020

Conversation

dryajov
Copy link
Contributor

@dryajov dryajov commented Jun 28, 2020

This PR improves resource cleanup and reduces the number of LPChannel's in use as well as adds Cancelation support.

@dryajov dryajov requested a review from cheatfate June 28, 2020 16:56
@dryajov
Copy link
Contributor Author

dryajov commented Jun 28, 2020

@cheatfate can I get some 👀 on the cancelation logic that I added, I'm not 100% sure I've got it right.

trace "deleted channel"
finally:
trace "stopping mplex main loop", oid = m.oid
defer:
Copy link
Contributor

Choose a reason for hiding this comment

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

defer inside of try block you are trying to break it really, finally here is much more natural from my point of view.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

With all things being equal, I think defer is cleaner than a bunch of nested try/finally, but it is a matter of preference. Hopefully, defer wont break this time tho 😄

Copy link
Contributor

Choose a reason for hiding this comment

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

fwiw, defer has been proposed for removal from the language and has proven buggy before - it will not get as much attention on the compiler side.. finally might be the safer option overall

libp2p/muxers/muxer.nim Outdated Show resolved Hide resolved
@dryajov dryajov marked this pull request as ready for review June 29, 2020 13:17
@dryajov
Copy link
Contributor Author

dryajov commented Jun 29, 2020

I can take care of the defers in a separate PR, going to move this one forward as it resolves a lot of our current issues.

@dryajov dryajov merged commit c788a6a into master Jun 29, 2020
@dryajov dryajov deleted the cleanup-resources branch June 29, 2020 15:15
dryajov added a commit that referenced this pull request Jul 2, 2020
* consolidate reading in lpstream

* remove debug echo

* tune log level

* add channel cleanup and cancelation handling

* cancelation handling

* cancelation handling

* cancelation handling

* cancelation handling

* cleanup and cancelation handling

* cancelation handling

* cancelation

* tests

* rename isConnected to connected

* remove testing trace

* comment out debug stacktraces

* explicit raises
dryajov added a commit that referenced this pull request Jul 7, 2020
* consolidate reading in lpstream

* remove debug echo

* tune log level

* add channel cleanup and cancelation handling

* cancelation handling

* cancelation handling

* cancelation handling

* cancelation handling

* cleanup and cancelation handling

* cancelation handling

* cancelation

* tests

* rename isConnected to connected

* remove testing trace

* comment out debug stacktraces

* explicit raises
dryajov added a commit that referenced this pull request Jul 8, 2020
* use var semantics to optimize table access

* wip... lvalues don't work properly sadly...

* big publish refactor, replenish and balance

* fix internal tests

* use g.peers for fanout (todo: don't include flood peers)

* exclude non gossip from fanout

* internal test fixes

* fix flood tests

* fix test's trypublish

* test interop fixes

* make sure to not remove peers from gossip table

* restore old replenishFanout

* cleanups

* Cleanup resources (#246)

* consolidate reading in lpstream

* remove debug echo

* tune log level

* add channel cleanup and cancelation handling

* cancelation handling

* cancelation handling

* cancelation handling

* cancelation handling

* cleanup and cancelation handling

* cancelation handling

* cancelation

* tests

* rename isConnected to connected

* remove testing trace

* comment out debug stacktraces

* explicit raises

* restore trace vs debug in gossip

* improve fanout replenish behavior further

* cleanup stale peers more eaguerly

* synchronize connection cleanup and small refactor

* close client first and call parent second

* disconnect failed peers on publish

* check for publish result

* fix tests

* fix tests

* always call close

Co-authored-by: Giovanni Petrantoni <[email protected]>
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.

3 participants