From owner-freebsd-current@FreeBSD.ORG Mon Nov 5 05:02:15 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 3871916A419 for ; Mon, 5 Nov 2007 05:02:15 +0000 (UTC) (envelope-from ianf@clue.co.za) Received: from munchkin.clue.co.za (munchkin.clue.co.za [66.219.59.160]) by mx1.freebsd.org (Postfix) with ESMTP id D8FA713C4BD for ; Mon, 5 Nov 2007 05:02:14 +0000 (UTC) (envelope-from ianf@clue.co.za) DomainKey-Signature: a=rsa-sha1; q=dns; c=simple; s=20070313; d=clue.co.za; h=Received:Received:Received:To:cc:From:Subject:In-Reply-To:X-Attribution:Date:Message-Id; b=NZIyC95MpZipC8bF17y1MzlyH52+gtv92eAgCZl8bEUNO4Pt5GpIIF3RAWWdJa45nKKqVmu3eNGUtcqDxfoIscop81dGr93gmPQYBcBpfz3d6Ft0SM2tz/Xz+l27w1AVURRJB1ZbSaLedkM9EFjJM7tlqsXPTcp+sEE1TmNN1TgEgnLoYnk/5Vq2eMvxHnlV6dYZnzsPNx59MuabG7K54ZcGa8Y3H8v6R4b7/+m2i0orUjD6OSLXJbj49hG6KOEV; Received: from uucp by munchkin.clue.co.za with local-rmail (Exim 4.67) (envelope-from ) id 1Iou6E-0004Aj-HV; Mon, 05 Nov 2007 05:02:10 +0000 Received: from ianf.clue.co.za ([10.0.0.6] helo=clue.co.za) by urchin.clue.co.za with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.66) (envelope-from ) id 1Iou5u-0007pG-RT; Mon, 05 Nov 2007 05:01:51 +0000 Received: from localhost ([127.0.0.1] helo=clue.co.za) by clue.co.za with esmtp (Exim 4.68 (FreeBSD)) (envelope-from ) id 1Iou5t-0000UY-KK; Mon, 05 Nov 2007 07:01:49 +0200 To: Robert Watson From: Ian FREISLICH In-Reply-To: Message from Robert Watson of "Fri, 02 Nov 2007 16:26:45 +0100." <20071102162523.A47979@fledge.watson.org> X-Attribution: BOFH Date: Mon, 05 Nov 2007 07:01:49 +0200 Message-Id: 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: Mon, 05 Nov 2007 05:02:15 -0000 Robert Watson wrote: > 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. The connection was closed long before the call to sendfile by the remote side. Is there a way to determine how much actually made it onto the wire? Presumably this is actually known somewhere in the kernel. Ian -- Ian Freislich