apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s.@apache.org
Subject svn commit: r1073146 - in /apr/apr/branches/1.4.x: CHANGES file_io/unix/readwrite.c
Date Mon, 21 Feb 2011 21:28:37 GMT
Author: sf
Date: Mon Feb 21 21:28:37 2011
New Revision: 1073146

URL: http://svn.apache.org/viewvc?rev=1073146&view=rev
Log:
apr_file_flush_locked(): Handle short writes.

Modified:
    apr/apr/branches/1.4.x/CHANGES
    apr/apr/branches/1.4.x/file_io/unix/readwrite.c

Modified: apr/apr/branches/1.4.x/CHANGES
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.4.x/CHANGES?rev=1073146&r1=1073145&r2=1073146&view=diff
==============================================================================
--- apr/apr/branches/1.4.x/CHANGES [utf-8] (original)
+++ apr/apr/branches/1.4.x/CHANGES [utf-8] Mon Feb 21 21:28:37 2011
@@ -1,6 +1,8 @@
                                                      -*- coding: utf-8 -*-
 Changes for APR 1.4.3
 
+  *) apr_file_flush_locked(): Handle short writes. [Stefan Fritsch]
+
   *) apr_pollset_create_ex(): Trap errors from pollset providers.
      PR 49094.  [Sami Tolvanen <sami.tolvanen mywot.com>]
 

Modified: apr/apr/branches/1.4.x/file_io/unix/readwrite.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.4.x/file_io/unix/readwrite.c?rev=1073146&r1=1073145&r2=1073146&view=diff
==============================================================================
--- apr/apr/branches/1.4.x/file_io/unix/readwrite.c (original)
+++ apr/apr/branches/1.4.x/file_io/unix/readwrite.c Mon Feb 21 21:28:37 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;



Mime
View raw message