From dev-return-19946-apmail-apr-dev-archive=apr.apache.org@apr.apache.org Fri Apr 25 01:39:02 2008 Return-Path: Delivered-To: apmail-apr-dev-archive@www.apache.org Received: (qmail 60139 invoked from network); 25 Apr 2008 01:39:02 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 25 Apr 2008 01:39:02 -0000 Received: (qmail 26450 invoked by uid 500); 25 Apr 2008 01:39:03 -0000 Delivered-To: apmail-apr-dev-archive@apr.apache.org Received: (qmail 26381 invoked by uid 500); 25 Apr 2008 01:39:03 -0000 Mailing-List: contact dev-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Id: Delivered-To: mailing list dev@apr.apache.org Received: (qmail 26364 invoked by uid 99); 25 Apr 2008 01:39:03 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 24 Apr 2008 18:39:02 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy) Received: from [208.97.132.202] (HELO spunkymail-a11.g.dreamhost.com) (208.97.132.202) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 25 Apr 2008 01:38:10 +0000 Received: from angry.angryparsley.ath.cx (c-76-126-162-229.hsd1.ca.comcast.net [76.126.162.229]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by spunkymail-a11.g.dreamhost.com (Postfix) with ESMTP id 8298AB89CF for ; Thu, 24 Apr 2008 18:38:30 -0700 (PDT) Message-Id: <77024D80-3994-4FD4-B74E-1598756A6769@mipsisrisc.com> From: Geoff Greer To: dev@apr.apache.org In-Reply-To: <11286.64.172.17.3.1209066267.squirrel@webmail.mipsisrisc.com> Content-Type: multipart/mixed; boundary=Apple-Mail-23-999555355 Mime-Version: 1.0 (Apple Message framework v919.2) Subject: Re: Patch to fix sendfile on OS X Date: Thu, 24 Apr 2008 18:38:25 -0700 References: <11286.64.172.17.3.1209066267.squirrel@webmail.mipsisrisc.com> X-Mailer: Apple Mail (2.919.2) X-Virus-Checked: Checked by ClamAV on apache.org --Apple-Mail-23-999555355 Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Ugh, I actually broke apr_socket_sendfile on OS X when I cleaned up my code for submission. Here is a patch for my patch. Fixes are: 1. nbytes is initialized properly so if we only send the header we don't lie and say we sent header bytes + file length. - apr_off_t nbytes = *len; + apr_off_t nbytes = 0; 2. Vestigial code removed. - else { - header_bytes_written = 0; - } 3. Bytes sent in the header are now counted. - (*len) = nbytes; + (*len) = nbytes + header_bytes_written; Patch attached, hopefully in text/plain. Geoff --Apple-Mail-23-999555355 Content-Disposition: attachment; filename=sendrecv.c.patch.txt Content-Type: text/plain; x-unix-mode=0644; name="sendrecv.c.patch.txt" Content-Transfer-Encoding: 7bit Index: sendrecv.c =================================================================== --- sendrecv.c (revision 651459) +++ sendrecv.c (working copy) @@ -410,7 +410,7 @@ apr_hdtr_t * hdtr, apr_off_t * offset, apr_size_t * len, apr_int32_t flags) { - apr_off_t nbytes = *len; + apr_off_t nbytes = 0; apr_off_t bytes_to_send = *len; apr_size_t header_bytes_written = 0; int rv; @@ -445,9 +445,6 @@ header_bytes_written = rv; rv = 0; } - else { - header_bytes_written = 0; - } } else if (bytes_to_send) { /* We won't dare call sendfile() if we don't have @@ -513,7 +510,7 @@ } } while (rv == -1 && (errno == EINTR || errno == EAGAIN)); - (*len) = nbytes; + (*len) = nbytes + header_bytes_written; if (rv == -1) { return errno; } --Apple-Mail-23-999555355 Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit On Apr 24, 2008, at 12:44 PM, Geoff Greer wrote: > Instead of my last suggestion to disable sendfile on 10.5, I've fixed > apr_socket_sendfile. The patch is attached. You can apply it by > checking > out trunk: > > cd apr/network_io/unix > patch -p0 < sendrecv.c.patch > > Now the sendfile test case passes on OS X. This is my first real > patch, so > suggestions are welcome. > > Geoff --Apple-Mail-23-999555355--