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

ULimit #169

Merged
merged 8 commits into from Apr 6, 2020
Merged

ULimit #169

merged 8 commits into from Apr 6, 2020

Conversation

kayabaNerve
Copy link
Member

Partially fixes #158.

The Chronos branch hopefully fixed socket leakage. This branch makes sure Meros never accepts so many peers the RPC locks itself off, and when a node hits its capacity, implements a new message to redirect to other nodes.

This branch only has theoretical macOS/BSD support and doesn't have Windows support. That said, Windows already isn't officially supported, so I'm not too concerned about this.

Keeps track of the amount of file Meros is allowed to use and how many 
it is using. Uses a mix of regular updating and estimation of how many 
new files have been created.

When Meros is `BUFFER_FILES` near its limit, it starts recommending not 
handling peers/not attempting connections.

Should work on Linux and macOS. Windows is not currently supported, 
though the WINAPI functions seem to be well documented. Adds a 
compile-time UnsupportedTarget error which is raised when compilation is 
attempted on an unsupport target (mainly Windows, but technically 
Solaris and Haiku as well).
Also sends Busy to people who connect to us when we don't have files 
available, a currently undocumented network message equivalent to Peers 
yet only used as a HandshakeSyncing response.
Also fixes some misc errors in the docs.
This test doesn't verify FDs are never leaked, which is exceptionally 
difficult to do. It creates sockets until it gets Busy, creates 2x the 
buffer to make sure busy sockets are closed, disconnects 50 sockets, 
reconnects them, and verifies any new socket gets Busy.

I originally thought this test discovered a FD leak in the form of the 
timers. 3 timers are set during the test, and Meros could only reconnect 
47 sockets. That said, it's actually an issue with our original 
presumption of how many FDs are open. mainRPC is called AFTER the 
Network is connected and opens 3 new FDs.

This test now (compared to my first draft) waits a minute before running 
for Meros to correct itself. I added clearTimer statements in case they 
helped, and they are left because they cannot hurt.

I don't feel a need to fix the 3-file difference in Meros because I 
doubt 495 unique IPs will connect within the first minute of operation. 
Even if they did, we'd still have 13 buffer FDs.
Also tweaks the ULimit test to make sure it passes the checks we employ.
@kayabaNerve kayabaNerve merged commit fdc590c into master Apr 6, 2020
@kayabaNerve kayabaNerve deleted the ulimit branch April 6, 2020 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Meros's ULimit code doesn't support Windows and is untested.
1 participant