apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s.@apache.org
Subject svn commit: r1073145 - /apr/apr/branches/1.5.x/file_io/unix/readwrite.c
Date Mon, 21 Feb 2011 21:26:26 GMT
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;



Mime
View raw message