From owner-freebsd-current@FreeBSD.ORG Fri Nov 2 20:14:45 2007 Return-Path: Delivered-To: current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3682A16A418 for ; Fri, 2 Nov 2007 20:14:45 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from cyrus.watson.org (cyrus.watson.org [209.31.154.42]) by mx1.freebsd.org (Postfix) with ESMTP id 099A313C4B2 for ; Fri, 2 Nov 2007 20:14:44 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from fledge.watson.org (fledge.watson.org [209.31.154.41]) by cyrus.watson.org (Postfix) with ESMTP id DB11546CBE; Fri, 2 Nov 2007 10:26:45 -0500 (EST) Date: Fri, 2 Nov 2007 16:26:45 +0100 (BST) From: Robert Watson X-X-Sender: robert@fledge.watson.org To: Ian FREISLICH In-Reply-To: Message-ID: <20071102162523.A47979@fledge.watson.org> References: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: current@freebsd.org Subject: Re: sendfile() not detecting closed connections. X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 02 Nov 2007 20:14:45 -0000 On Fri, 2 Nov 2007, Ian FREISLICH wrote: > sendfile() reports success for files less than about 64k in size, but I > haven't been able to figure out where the threshold is. It erroneously > reports that 41000 of the 64k were sent, but will say the whole file was > transferred up to about 64k. The connection filedescriptor is blocking. Probably what is happening is that sendfile() is counting bytes successfully inserted into the send socket buffer, rather than bytes sent on the wire. This is consistent with what happens when you write a file to a TCP socket, though, as you only know the bytes made it into the buffer, not to the remote destination. I'd guess the threshold size you're seeing above is the size of the default send socket buffer. Robert N M Watson Computer Laboratory University of Cambridge