Return-Path: Delivered-To: apmail-apr-dev-archive@www.apache.org Received: (qmail 3034 invoked from network); 4 Feb 2011 23:33:24 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 4 Feb 2011 23:33:24 -0000 Received: (qmail 61506 invoked by uid 500); 4 Feb 2011 23:33:24 -0000 Delivered-To: apmail-apr-dev-archive@apr.apache.org Received: (qmail 61431 invoked by uid 500); 4 Feb 2011 23:33:23 -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 61423 invoked by uid 99); 4 Feb 2011 23:33:23 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 04 Feb 2011 23:33:23 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of blair@orcaware.com designates 108.0.197.17 as permitted sender) Received: from [108.0.197.17] (HELO orca3.orcaware.com) (108.0.197.17) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 04 Feb 2011 23:33:15 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) by orca3.orcaware.com (8.14.3/8.14.3/Debian-9.2ubuntu1) with ESMTP id p14NWpid015794; Fri, 4 Feb 2011 15:32:52 -0800 From: Blair Zajac Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Date: Fri, 4 Feb 2011 15:32:51 -0800 Subject: [PATCH] apr_file_flush_locked and short writes To: dev@apr.apache.org Message-Id: Mime-Version: 1.0 (Apple Message framework v1082) X-Mailer: Apple Mail (2.1082) X-Virus-Checked: Checked by ClamAV on apache.org Looking at apr_file_flush_locked(), it looks like it doesn't handle = short writes for buffered apr_file_t's, upon a short write the unwritten = data will be lost. Here's a patch for this: Index: file_io/unix/readwrite.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- file_io/unix/readwrite.c (revision 1067340) +++ file_io/unix/readwrite.c (working copy) @@ -409,7 +409,11 @@ rv =3D errno; } else { thefile->filePtr +=3D written; - thefile->bufpos =3D 0; + if (written !=3D thefile->bufpos) + memmove(thefile->buffer, + thefile->buffer + written, + thefile->bufpos - written); + thefile->bufpos -=3D written; } } =20 Beyond this, there's no a mechanism to report that all the buffered data = didn't get into the file. Perhaps apr_file_flush() should loop until = the entire buffer is written or it gets a non-EINTR error? Blair