------------------------------------------------------------ revno: 12448 revision-id: squid3@treenet.co.nz-20130109001202-xx9pa0oujcpvw072 parent: squid3@treenet.co.nz-20130108223952-0jvvrjn0yonrvokf fixes bug(s): http://bugs.squid-cache.org/show_bug.cgi?id=3731 committer: Amos Jeffries branch nick: 3.3 timestamp: Tue 2013-01-08 17:12:02 -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-20130109001202-xx9pa0oujcpvw072 # target_branch: http://bzr.squid-cache.org/bzr/squid3/3.3 # testament_sha1: 50f0c6d4a95b1c703ec3e4178f16c379fb0fb7e1 # timestamp: 2013-01-09 00:14:05 +0000 # source_branch: http://bzr.squid-cache.org/bzr/squid3/3.3 # base_revision_id: squid3@treenet.co.nz-20130108223952-\ # 0jvvrjn0yonrvokf # # Begin patch === modified file 'src/ip/Qos.cci' --- src/ip/Qos.cci 2012-08-14 11:53:07 +0000 +++ src/ip/Qos.cci 2013-01-09 00:12:02 +0000 @@ -5,8 +5,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;