diff options
author | Nick Mathewson <nickm@torproject.org> | 2007-11-02 14:50:37 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2007-11-02 14:50:37 +0000 |
commit | e76581f97eb849a0e3de869828f4ff809d00e9ba (patch) | |
tree | 5a064235a2136598fc3cf20477e3de5bf1460fe6 /src/common | |
parent | 6aeca5237d3e801cc6da07a83af22bb159be703b (diff) | |
download | tor-e76581f97eb849a0e3de869828f4ff809d00e9ba.tar.gz tor-e76581f97eb849a0e3de869828f4ff809d00e9ba.zip |
r14647@tombo: nickm | 2007-11-02 10:48:37 -0400
Use rlim_t instead of unsigned long to manipulate rlimit values.
svn:r12339
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/compat.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/common/compat.c b/src/common/compat.c index 1bc653f25a..b46591701e 100644 --- a/src/common/compat.c +++ b/src/common/compat.c @@ -663,6 +663,10 @@ tor_socketpair(int family, int type, int protocol, int fd[2]) #define ULIMIT_BUFFER 32 /* keep 32 extra fd's beyond _ConnLimit */ +#if defined(HAVE_GETRLIMIT) && !defined(HAVE_RLIM_T) +typedef unsigned long rlim_t; +#endif + /** Learn the maximum allowed number of file descriptors. (Some systems * have a low soft limit. * @@ -684,7 +688,7 @@ set_max_file_descriptors(unsigned long limit, unsigned long cap) } #else struct rlimit rlim; - unsigned long most; + rlim_t most; tor_assert(limit > 0); tor_assert(cap > 0); @@ -693,16 +697,17 @@ set_max_file_descriptors(unsigned long limit, unsigned long cap) strerror(errno)); return -1; } + //log_notice(LD_CONFIG, "%llu %llu", rlim.rlim_cur, rlim.rlim_max); if ((unsigned long)rlim.rlim_max < limit) { log_warn(LD_CONFIG,"We need %lu file descriptors available, and we're " "limited to %lu. Please change your ulimit -n.", limit, (unsigned long)rlim.rlim_max); return -1; } - most = ((unsigned long)rlim.rlim_max > cap) ? cap : (unsigned) rlim.rlim_max; + most = rlim.rlim_max > (rlim_t)cap ? (rlim_t)cap : rlim.rlim_max; if (most > (unsigned long)rlim.rlim_cur) { log_info(LD_NET,"Raising max file descriptors from %lu to %lu.", - (unsigned long)rlim.rlim_cur, most); + (unsigned long)rlim.rlim_cur, (unsigned long)most); } rlim.rlim_cur = most; if (setrlimit(RLIMIT_NOFILE, &rlim) != 0) { |