------------------------------------------------------------ revno: 11745 revision-id: squid3@treenet.co.nz-20130109001443-rcqnrorstrkowldo parent: squid3@treenet.co.nz-20130108224018-5g5t67qy79rnboih fixes bug(s): http://bugs.squid-cache.org/show_bug.cgi?id=3731 committer: Amos Jeffries branch nick: 3.2 timestamp: Tue 2013-01-08 17:14:43 -0700 message: Bug 3731: TOS setsockopt() requires int value FreeBSD is confirmed errors 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 working 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. ------------------------------------------------------------ # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: squid3@treenet.co.nz-20130109001443-rcqnrorstrkowldo # target_branch: http://bzr.squid-cache.org/bzr/squid3/branches\ # /SQUID_3_2 # testament_sha1: de3f04a5a4eaa92ca66ebb0fbb24d5d6e7c4e735 # timestamp: 2013-01-09 00:15:37 +0000 # source_branch: http://bzr.squid-cache.org/bzr/squid3/branches\ # /SQUID_3_2 # base_revision_id: squid3@treenet.co.nz-20130108224018-\ # 5g5t67qy79rnboih # # Begin patch === modified file 'src/ip/Qos.cci' --- src/ip/Qos.cci 2012-07-28 05:38:50 +0000 +++ src/ip/Qos.cci 2013-01-09 00:14:43 +0000 @@ -4,8 +4,13 @@ int Ip::Qos::setSockTos(const Comm::ConnectionPointer &conn, tos_t tos) { -#ifdef IP_TOS - int x = setsockopt(conn->fd, IPPROTO_IP, IP_TOS, &tos, sizeof(tos_t)); +#if defined(IP_TOS) + // Bug 3731: FreeBSD produces 'invalid option' + // unless we pass it a 32-bit variable storing 8-bits of data. + // 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)); if (x < 0) debugs(50, 2, "Ip::Qos::setSockTos: setsockopt(IP_TOS) on " << conn << ": " << xstrerror()); return x;