Return-Path: Delivered-To: apmail-apr-dev-archive@www.apache.org Received: (qmail 51318 invoked from network); 7 May 2008 18:32:30 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 7 May 2008 18:32:30 -0000 Received: (qmail 79214 invoked by uid 500); 7 May 2008 18:32:31 -0000 Delivered-To: apmail-apr-dev-archive@apr.apache.org Received: (qmail 79170 invoked by uid 500); 7 May 2008 18:32:30 -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 79159 invoked by uid 99); 7 May 2008 18:32:30 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 May 2008 11:32:30 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of dirkx@webweaving.org designates 209.132.96.45 as permitted sender) Received: from [209.132.96.45] (HELO skutsje.san.webweaving.org) (209.132.96.45) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 May 2008 18:31:44 +0000 Received: from [10.11.0.121] (5356CA0A.cable.casema.nl [83.86.202.10]) (authenticated bits=0) by skutsje.san.webweaving.org (8.12.9/8.12.9) with ESMTP id m47IVr2Q055334 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO); Wed, 7 May 2008 11:31:56 -0700 (PDT) (envelope-from dirkx@webweaving.org) Cc: APR Developer List Message-Id: <9E084011-40B5-4906-9507-36BDDE2C0852@webweaving.org> From: Dirk-Willem van Gulik To: Jim Jagielski In-Reply-To: <7D1DBBCE-871D-44ED-A6EC-8B9105C6C3E2@jaguNET.com> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v919.2) Subject: Re: sendfile in darwin Date: Wed, 7 May 2008 20:31:53 +0200 References: <48209AFD.9030604@rowe-clan.net> <2EA94233-5650-4168-9071-EE9B4B451C86@jaguNET.com> <3B4823DC-C723-47C8-85F6-01C25947728D@jaguNET.com> <827F5091-3959-41C0-8286-777AA3643885@jaguNET.com> <7D1DBBCE-871D-44ED-A6EC-8B9105C6C3E2@jaguNET.com> X-Mailer: Apple Mail (2.919.2) X-Virus-Checked: Checked by ClamAV on apache.org Hmm - Jim - that does not quite solve the issue I was discussing on IRC; I think below is needed (which does solve the TimeOut issue). --> diff with your version -- anticipate nbytes set to 0 (which has whole file semantics on BSD and Darwin). Does that make sense ? Dw Index: network_io/unix/sendrecv.c =================================================================== --- network_io/unix/sendrecv.c (revision 648693) +++ network_io/unix/sendrecv.c (working copy) @@ -438,6 +438,7 @@ } } if (nbytes) { + int nnbytes = nbytes; /* We won't dare call sendfile() if we don't have * header or file bytes to send because nbytes == 0 * means send the remaining file to EOF. @@ -445,7 +446,7 @@ rv = sendfile(file->filedes, /* file to be sent */ sock->socketdes, /* socket */ *offset, /* where in the file to start */ - &nbytes, /* number of bytes to write/ written */ + &nnbytes, /* number of bytes to write/ written */ &headerstruct, /* Headers/footers */ flags); /* undefined, set to 0 */ @@ -453,12 +454,13 @@ if (errno == EAGAIN) { if (sock->timeout > 0) { sock->options |= APR_INCOMPLETE_WRITE; + rv = 0; } /* BSD's sendfile can return -1/EAGAIN even if it * sent bytes. Sanitize the result so we get normal EAGAIN * semantics w.r.t. bytes sent. */ - if (nbytes) { + if (nnbytes) { /* normal exit for a big file & non-blocking io */ (*len) = nbytes; return APR_SUCCESS; @@ -466,7 +468,7 @@ } } else { /* rv == 0 (or the kernel is broken) */ - if (nbytes == 0) { + if (nnbytes == 0) { /* Most likely the file got smaller after the stat. * Return an error so the caller can do the Right Thing. */