From: Amos Jeffries Date: Thu, 7 Apr 2011 14:52:13 +0000 (+1200) Subject: Portability Fix: getrlimit() / setrlimit() incompatible type 'struct rlimit' X-Git-Tag: take06~27^2~22 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8527a56ff945230c4ae81cadc9ef3728ebb57716;p=thirdparty%2Fsquid.git Portability Fix: getrlimit() / setrlimit() incompatible type 'struct rlimit' On Linux (at least) with large file support but not full 64-bit environment. The getrlimt / setrlimit are #define'd to getrlimite64 / setrlimit64 BUT, the struct rlimit internal fields are updated to 64-bit types individually instead of a matching #define to struct rlimit64 as a whole. One can only assume that GCC is casting to void* or some such major voodoo which hides this type collision. --- diff --git a/src/tools.cc b/src/tools.cc index 7f9353f78e..2610b3fc2e 100644 --- a/src/tools.cc +++ b/src/tools.cc @@ -966,7 +966,16 @@ void setMaxFD(void) { #if HAVE_SETRLIMIT && defined(RLIMIT_NOFILE) + +/* On Linux with 64-bit file support the sys/resource.h header + * uses #define to change the function definition to require rlimit64 + */ +#if defined(getrlimit) + struct rlimit64 rl; // Assume its a 64-bit redefine anyways. +#else struct rlimit rl; +#endif + if (getrlimit(RLIMIT_NOFILE, &rl) < 0) { debugs(50, DBG_CRITICAL, "setrlimit: RLIMIT_NOFILE: " << xstrerror()); } else if (Config.max_filedescriptors > 0) { @@ -1002,7 +1011,16 @@ setSystemLimits(void) { #if HAVE_SETRLIMIT && defined(RLIMIT_NOFILE) && !_SQUID_CYGWIN_ /* limit system filedescriptors to our own limit */ + + /* On Linux with 64-bit file support the sys/resource.h header + * uses #define to change the function definition to require rlimit64 + */ +#if defined(getrlimit) + struct rlimit64 rl; // Assume its a 64-bit redefine anyways. +#else struct rlimit rl; +#endif + if (getrlimit(RLIMIT_NOFILE, &rl) < 0) { debugs(50, DBG_CRITICAL, "setrlimit: RLIMIT_NOFILE: " << xstrerror()); } else {