]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Portability Fix: getrlimit() / setrlimit() incompatible type 'struct rlimit'
authorAmos Jeffries <squid3@treenet.co.nz>
Thu, 7 Apr 2011 14:52:13 +0000 (02:52 +1200)
committerAmos Jeffries <squid3@treenet.co.nz>
Thu, 7 Apr 2011 14:52:13 +0000 (02:52 +1200)
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.

src/tools.cc

index 7f9353f78eb6e508da4c8a0d2debd4cfcc8c492a..2610b3fc2e0c48dfc764183aa859a12e5c6f0656 100644 (file)
@@ -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 {