------------------------------------------------------------ revno: 14063 revision-id: squid3@treenet.co.nz-20160630205154-a7wuev6kk7v5f1y8 parent: squid3@treenet.co.nz-20160630204753-v54bf0cj4n49hfsy author: Alex Rousskov committer: Amos Jeffries branch nick: 3.5 timestamp: Fri 2016-07-01 08:51:54 +1200 message: Do not make bogus recvmsg(2) calls when closing UDS sockets. comm_empty_os_read_buffers() assumes that all non-blocking FD_READ_METHODs can read into an opaque buffer filled with random characters. That assumption is wrong for UDS sockets that require an initialized msghdr structure. Feeding random data to recvmsg(2) leads to confusing errors, at best. Squid does not log those errors, but they are visible in, for example, strace: recvmsg(17, 0x7fffbb, MSG_DONTWAIT) = -1 EMSGSIZE (Message too long) comm_empty_os_read_buffers() is meant to prevent TCP RST packets. The function now ignores UDS sockets that are not used for TCP. TODO: Useless reads may also exist for UDP and some TCP sockets. ------------------------------------------------------------ # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: squid3@treenet.co.nz-20160630205154-a7wuev6kk7v5f1y8 # target_branch: http://bzr.squid-cache.org/bzr/squid3/3.5 # testament_sha1: e79a8b223e6b648ae6051f2f6fb163152802b51a # timestamp: 2016-06-30 21:04:44 +0000 # source_branch: http://bzr.squid-cache.org/bzr/squid3/3.5 # base_revision_id: squid3@treenet.co.nz-20160630204753-\ # v54bf0cj4n49hfsy # # Begin patch === modified file 'src/comm.cc' --- src/comm.cc 2016-04-11 12:41:38 +0000 +++ src/comm.cc 2016-06-30 20:51:54 +0000 @@ -110,7 +110,7 @@ /* prevent those nasty RST packets */ char buf[SQUID_TCP_SO_RCVBUF]; - if (fd_table[fd].flags.nonblocking) { + if (fd_table[fd].flags.nonblocking && fd_table[fd].type != FD_MSGHDR) { while (FD_READ_METHOD(fd, buf, SQUID_TCP_SO_RCVBUF) > 0) {}; } #endif