Re: Why does ~DeferredReadManager read?

From: Robert Collins <robertc_at_robertcollins.net>
Date: Sun, 02 Nov 2008 06:38:19 +1100

On Sat, 2008-11-01 at 10:45 -0600, Alex Rousskov wrote:
>
> Moreover, if we must read until EOF before we close, then the cleanup
> code would have to be rewritten in many places, not just the deferred
> read-related ones!

src/comm.cc line 353:
/**
 * Empty the read buffers
 *
 * This is a magical routine that empties the read buffers.
 * Under some platforms (Linux) if a buffer has data in it before
 * you call close(), the socket will hang and take quite a while
 * to timeout.
 */
static void
comm_empty_os_read_buffers(int fd)
{
#ifdef _SQUID_LINUX_
    /* prevent those nasty RST packets */
    char buf[SQUID_TCP_SO_RCVBUF];

    if (fd_table[fd].flags.nonblocking == 1) {
        while (FD_READ_METHOD(fd, buf, SQUID_TCP_SO_RCVBUF) > 0) {};
    }
#endif
}

-- 
GPG key available at: <http://www.robertcollins.net/keys.txt>.

Received on Sat Nov 01 2008 - 19:38:25 MDT

This archive was generated by hypermail 2.2.0 : Sun Nov 02 2008 - 12:00:03 MST