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
This commit is contained in:
parent
ad7837d925
commit
75299426d0
12
configure.in
12
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([
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue