From: Amos Jeffries Date: Mon, 18 Apr 2011 11:53:13 +0000 (-0600) Subject: Portability Fix: getrlimit() / setrlimit() incompatible type 'struct rlimit' X-Git-Tag: SQUID_3_1_12_1~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b59662624bb3b5282ae523f851b63ce2cbe25761;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 4c08696bdf..ad2c212b10 100644 --- a/src/tools.cc +++ b/src/tools.cc @@ -880,7 +880,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) { @@ -916,7 +925,16 @@ setSystemLimits(void) { #if HAVE_SETRLIMIT && defined(RLIMIT_NOFILE) && !defined(_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 {