]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bug 3731: use 'int' on all systems settign TOS value.
authorAmos Jeffries <squid3@treenet.co.nz>
Tue, 8 Jan 2013 23:51:02 +0000 (16:51 -0700)
committerAmos Jeffries <squid3@treenet.co.nz>
Tue, 8 Jan 2013 23:51:02 +0000 (16:51 -0700)
FreeBSD is confirmed erroring out on 8-bit variable size. Other BSD are
documented in a way that implies they do as well, although not at this
stage confirmed to be failing.
 Linux seems to be the only confirmed system workign with 8-bit size sent
to setsockopt(). So we revert this to 'int' (32-bit or 64-bit) as was
working in Squid 3.1.

src/ip/Qos.cci

index 2411fa9545b4750b8e563415c3719418fa058f09..97a5918a4035242780d05a2b901614297db404b9 100644 (file)
@@ -8,12 +8,10 @@ Ip::Qos::setSockTos(const Comm::ConnectionPointer &conn, tos_t tos)
 #if defined(IP_TOS)
     // Bug 3731: FreeBSD produces 'invalid option'
     // unless we pass it a 32-bit variable storing 8-bits of data.
-#if _SQUID_FREEBSD_
-    int32_t bTos = tos;
+    // NP: it is documented as 'int' for all systems, even those like Linux which accept 8-bit char
+    //     so we convert to a int before setting.
+    int bTos = tos;
     int x = setsockopt(conn->fd, IPPROTO_IP, IP_TOS, &bTos, sizeof(bTos));
-#else
-    int x = setsockopt(conn->fd, IPPROTO_IP, IP_TOS, &tos, sizeof(tos_t));
-#endif
     if (x < 0)
         debugs(50, 2, "Ip::Qos::setSockTos: setsockopt(IP_TOS) on " << conn << ": " << xstrerror());
     return x;