diff options
author | Nick Mathewson <nickm@torproject.org> | 2008-01-07 19:51:42 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2008-01-07 19:51:42 +0000 |
commit | 75299426d0fc94622347a845746e1a61408a64e0 (patch) | |
tree | e8c98c9b96e424590c2fec73f408f93f92f58c25 | |
parent | ad7837d925d2e9d3752c3860f7b41e63df31884d (diff) | |
download | tor-75299426d0fc94622347a845746e1a61408a64e0.tar.gz tor-75299426d0fc94622347a845746e1a61408a64e0.zip |
r17505@catbus: nickm | 2008-01-07 14:51:37 -0500
Backport r12339 with fix in r12931: Work on platforms where rlim_t is wider than unsigned long.
svn:r13059
-rw-r--r-- | configure.in | 12 | ||||
-rw-r--r-- | doc/TODO.012 | 2 | ||||
-rw-r--r-- | src/common/compat.c | 10 |
3 files changed, 20 insertions, 4 deletions
diff --git a/configure.in b/configure.in index 98bf777567..6f3d024c9f 100644 --- a/configure.in +++ b/configure.in @@ -589,6 +589,18 @@ AC_CHECK_TYPES([struct in6_addr, struct sockaddr_storage], , , #include <sys/socket.h> #endif]) +AC_CHECK_TYPES([rlim_t], , , +[#ifdef HAVE_SYS_TYPES_H +#include <sys/types.h> +#endif +#ifdef HAVE_SYS_TIME_H +#include <sys/time.h> +#endif +#ifdef HAVE_SYS_RESOURCE_H +#include <sys/resource.h> +#endif +]) + if test -z "$CROSS_COMPILE"; then AC_CACHE_CHECK([whether time_t is signed], tor_cv_time_t_signed, [ AC_TRY_RUN([ diff --git a/doc/TODO.012 b/doc/TODO.012 index 5cba1b73cf..ded4265e39 100644 --- a/doc/TODO.012 +++ b/doc/TODO.012 @@ -9,7 +9,7 @@ Backport items for 0.1.2: - backport the osx privoxy.config changes X no need to backport the windows privoxy.config changes because they're not in SVN?? - - r12339: rlim_t may be wider than unsigned long. + o r12339: rlim_t may be wider than unsigned long. - r12341: Work if the real open-file limit is OPEN_FILES. o r12459: Exit policies reject public IP address too diff --git a/src/common/compat.c b/src/common/compat.c index 2d38aca80c..25bcde5912 100644 --- a/src/common/compat.c +++ b/src/common/compat.c @@ -606,6 +606,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. * @@ -627,7 +631,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); @@ -642,10 +646,10 @@ set_max_file_descriptors(unsigned long limit, unsigned long cap) limit, (unsigned long)rlim.rlim_max); return -1; } - most = (rlim.rlim_max > cap) ? cap : (unsigned) rlim.rlim_max; + most = (rlim.rlim_max > (rlim_t)cap) ? (rlim_t)cap : rlim.rlim_max; if (most > 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) { |