From 8732a244335488e672cf6dcdddf23d6b7454ce8d Mon Sep 17 00:00:00 2001 From: Nils Maier Date: Tue, 15 Jul 2014 08:16:13 +0200 Subject: Try to set sane limits for RLIMIT_NO_FILE E.g. on OSX the default is 256, which isn't exactly compatible with torrent downloads. Closes GH-257 --- src/OptionHandlerFactory.cc | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/OptionHandlerFactory.cc') diff --git a/src/OptionHandlerFactory.cc b/src/OptionHandlerFactory.cc index 409f2eab..f89a1c44 100644 --- a/src/OptionHandlerFactory.cc +++ b/src/OptionHandlerFactory.cc @@ -755,6 +755,25 @@ std::vector OptionHandlerFactory::createOptionHandlers() op->addTag(TAG_ADVANCED); handlers.push_back(op); } +#ifdef HAVE_SYS_RESOURCE_H + { + OptionHandler* op(new NumberOptionHandler + (PREF_RLIMIT_NOFILE, + TEXT_RLIMIT_NOFILE, + // Somewhat sane default that most *nix use. + // Some other *nix, like OSX, have insane defaults like + // 256, hence better *not* get the default value from + // getrlimit(). + "1024", + // 1 should not be a problem in practise, since the code + // will only adjust if the specified value > the current + // soft limit. + // And sane systems have a default soft limit > 1. + 1)); + op->addTag(TAG_ADVANCED); + handlers.push_back(op); + } +#endif // HAVE_SYS_RESOURCE_H { OptionHandler* op(new BooleanOptionHandler (PREF_SELECT_LEAST_USED_HOST, -- cgit