diff options
author | Nick Mathewson <nickm@torproject.org> | 2017-09-11 16:29:10 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2017-09-11 16:29:10 -0400 |
commit | c894e9d3d44bceaf209a9b73c2c43911af3eb1a8 (patch) | |
tree | c6c00b5d4575e2692422886e8f077cbc95906c2b /src | |
parent | f5092e711fb08dfdf7a356f8c58f10effe6fb831 (diff) | |
parent | 6a49e3360bcb30b267da4a47af749bd4571ee72d (diff) | |
download | tor-c894e9d3d44bceaf209a9b73c2c43911af3eb1a8.tar.gz tor-c894e9d3d44bceaf209a9b73c2c43911af3eb1a8.zip |
Merge branch 'maint-0.2.9' into maint-0.3.0
Diffstat (limited to 'src')
-rw-r--r-- | src/common/compat.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/common/compat.c b/src/common/compat.c index 4b8b73b4fc..7ec7030ecc 100644 --- a/src/common/compat.c +++ b/src/common/compat.c @@ -1732,19 +1732,24 @@ set_max_file_descriptors(rlim_t limit, int *max_out) if (setrlimit(RLIMIT_NOFILE, &rlim) != 0) { int bad = 1; #ifdef OPEN_MAX - if (errno == EINVAL && OPEN_MAX < rlim.rlim_cur) { + uint64_t try_limit = OPEN_MAX - ULIMIT_BUFFER; + if (errno == EINVAL && try_limit < (uint64_t) rlim.rlim_cur) { /* On some platforms, OPEN_MAX is the real limit, and getrlimit() is * full of nasty lies. I'm looking at you, OSX 10.5.... */ - rlim.rlim_cur = OPEN_MAX; + rlim.rlim_cur = try_limit; if (setrlimit(RLIMIT_NOFILE, &rlim) == 0) { if (rlim.rlim_cur < (rlim_t)limit) { log_warn(LD_CONFIG, "We are limited to %lu file descriptors by " - "OPEN_MAX, and ConnLimit is %lu. Changing ConnLimit; sorry.", - (unsigned long)OPEN_MAX, (unsigned long)limit); + "OPEN_MAX (%lu), and ConnLimit is %lu. Changing " + "ConnLimit; sorry.", + (unsigned long)try_limit, (unsigned long)OPEN_MAX, + (unsigned long)limit); } else { - log_info(LD_CONFIG, "Dropped connection limit to OPEN_MAX (%lu); " - "Apparently, %lu was too high and rlimit lied to us.", - (unsigned long)OPEN_MAX, (unsigned long)rlim.rlim_max); + log_info(LD_CONFIG, "Dropped connection limit to %lu based on " + "OPEN_MAX (%lu); Apparently, %lu was too high and rlimit " + "lied to us.", + (unsigned long)try_limit, (unsigned long)OPEN_MAX, + (unsigned long)rlim.rlim_max); } bad = 0; } |