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
===================================================================
--- file_io/unix/readwrite.c    (revision 1067340)
+++ file_io/unix/readwrite.c    (working copy)
@@ -409,7 +409,11 @@
             rv = errno;
         } else {
             thefile->filePtr += written;
-            thefile->bufpos = 0;
+            if (written != thefile->bufpos)
+                memmove(thefile->buffer,
+                        thefile->buffer + written,
+                        thefile->bufpos - written);
+            thefile->bufpos -= written;
         }
     }
 

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

Reply via email to