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

Added ability to set open file descriptor limit at run-time #89

Merged
merged 2 commits into from
Jul 14, 2014

Conversation

dndx
Copy link

@dndx dndx commented Jul 14, 2014

Instead of running ulimit -n from init script, we could utilize the POSIX setrlimit(2) system function and set the open file limit dynamically at run-time.

To do this, I added an optional config file variable called nofile. If nofile exists in the config file and it's value is greater than 0, then we will try to set RLIMIT_NOFILE when server starts.

Please note that on Linux, only privileged user could raise the hard limit, that's why we need to call setrlimit(2) before calling run_as. Upon failure to set RLIMIT_NOFILE, we simply output some helpful error message and keeps going.

Tested and confirmed to work on Linux 3.15.4 and Mac OS X 10.9.4.

Support of setrlimit(2) was added since Linux 2.6.36 and 4.2BSD.

madeye added a commit that referenced this pull request Jul 14, 2014
Added ability to set open file descriptor limit at run-time
@madeye madeye merged commit dc9f18a into shadowsocks:master Jul 14, 2014
@madeye
Copy link

madeye commented Jul 14, 2014

Great! Thanks for the patch. Merged.

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.

None yet

2 participants