From owner-freebsd-current@FreeBSD.ORG  Sun Nov 12 14:43:28 2006
Return-Path: <owner-freebsd-current@FreeBSD.ORG>
X-Original-To: freebsd-current@freebsd.org
Delivered-To: freebsd-current@freebsd.org
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 1CBB316A40F
	for <freebsd-current@freebsd.org>; Sun, 12 Nov 2006 14:43:28 +0000 (UTC)
	(envelope-from andre@freebsd.org)
Received: from c00l3r.networx.ch (c00l3r.networx.ch [62.48.2.2])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 7F21443D73
	for <freebsd-current@freebsd.org>; Sun, 12 Nov 2006 14:43:26 +0000 (GMT)
	(envelope-from andre@freebsd.org)
Received: (qmail 75956 invoked from network); 12 Nov 2006 14:36:29 -0000
Received: from dotat.atdotat.at (HELO [62.48.0.47]) ([62.48.0.47])
	(envelope-sender <andre@freebsd.org>)
	by c00l3r.networx.ch (qmail-ldap-1.03) with SMTP
	for <pawel.worach@gmail.com>; 12 Nov 2006 14:36:29 -0000
Message-ID: <4557330D.3010009@freebsd.org>
Date: Sun, 12 Nov 2006 15:43:25 +0100
From: Andre Oppermann <andre@freebsd.org>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US;
	rv:1.8b) Gecko/20050217
MIME-Version: 1.0
To: Pawel Worach <pawel.worach@gmail.com>
References: <200611021653.kA2GrRWx008044@repoman.freebsd.org>	<455530E0.5090000@gmail.com>
	<4555B45D.6020800@freebsd.org> <4555BA65.4020603@gmail.com>
In-Reply-To: <4555BA65.4020603@gmail.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Cc: freebsd-current@freebsd.org, amistry@am-productions.biz
Subject: Re: sendfile data corruption
X-BeenThere: freebsd-current@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: Discussions about the use of FreeBSD-current
	<freebsd-current.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/freebsd-current>, 
	<mailto:freebsd-current-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/freebsd-current>
List-Post: <mailto:freebsd-current@freebsd.org>
List-Help: <mailto:freebsd-current-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/freebsd-current>,
	<mailto:freebsd-current-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Sun, 12 Nov 2006 14:43:28 -0000

Pawel Worach wrote:
> Andre Oppermann wrote:
> 
>>
>> I'm looking into the problem.  Please try a binary FTP transfer as well
>> and check if the checksums match. ftpd uses sendfile(2) as well but w/o
>> headers or trailers and does the send in one swoop.
>>
> 
> Oh, didn't think of that, ftpd is ok, transferring a 64MB file does not 
> trash it. Meanwhile a couple of other things where tested, SMP disabled 
> (removed from kernel config), added some printf's which when printing to 
> a serial console moves the offset where the breakage begins to 
> 0x01000000, sometimes.

OK, I found the bug.  The sent byte count reporting was incorrect.  While
doing the sendfile(2) rewrite I got lost in the mixup of the FreeBSD 4.x
bug for bug compatibility.

Please try this patch:

  http://people.freebsd.org/~andre/sendfile_fix-20061112.diff

It fixes apache 2.0.59 for me.  For some reason lighttpd didn't suffer
from this problem, even w/o the fix.  Unfortunately that's what I tested
the rewrite against.

-- 
Andre