Return-Path: Delivered-To: apmail-apr-commits-archive@www.apache.org Received: (qmail 63579 invoked from network); 21 Feb 2011 21:26:50 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 21 Feb 2011 21:26:50 -0000 Received: (qmail 91087 invoked by uid 500); 21 Feb 2011 21:26:50 -0000 Delivered-To: apmail-apr-commits-archive@apr.apache.org Received: (qmail 91020 invoked by uid 500); 21 Feb 2011 21:26:49 -0000 Mailing-List: contact commits-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: Reply-To: dev@apr.apache.org List-Id: Delivered-To: mailing list commits@apr.apache.org Received: (qmail 91013 invoked by uid 99); 21 Feb 2011 21:26:49 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 21 Feb 2011 21:26:49 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 21 Feb 2011 21:26:47 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id BA08123889B2; Mon, 21 Feb 2011 21:26:26 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1073145 - /apr/apr/branches/1.5.x/file_io/unix/readwrite.c Date: Mon, 21 Feb 2011 21:26:26 -0000 To: commits@apr.apache.org From: sf@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110221212626.BA08123889B2@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: sf Date: Mon Feb 21 21:26:26 2011 New Revision: 1073145 URL: http://svn.apache.org/viewvc?rev=1073145&view=rev Log: apr_file_flush_locked(): Handle short writes. Modified: apr/apr/branches/1.5.x/file_io/unix/readwrite.c Modified: apr/apr/branches/1.5.x/file_io/unix/readwrite.c URL: http://svn.apache.org/viewvc/apr/apr/branches/1.5.x/file_io/unix/readwrite.c?rev=1073145&r1=1073144&r2=1073145&view=diff ============================================================================== --- apr/apr/branches/1.5.x/file_io/unix/readwrite.c (original) +++ apr/apr/branches/1.5.x/file_io/unix/readwrite.c Mon Feb 21 21:26:26 2011 @@ -311,12 +311,16 @@ apr_status_t apr_file_flush_locked(apr_f apr_status_t rv = APR_SUCCESS; if (thefile->direction == 1 && thefile->bufpos) { - apr_ssize_t written; + apr_ssize_t written = 0, ret; do { - written = write(thefile->filedes, thefile->buffer, thefile->bufpos); - } while (written == -1 && errno == EINTR); - if (written == -1) { + ret = write(thefile->filedes, thefile->buffer + written, + thefile->bufpos - written); + if (ret > 0) + written += ret; + } while (written < thefile->bufpos && + (ret > 0 || (ret == -1 && errno == EINTR))); + if (ret == -1) { rv = errno; } else { thefile->filePtr += written;