[I sent this to dev_at_apr.apache.org but haven't received a response.
Thread here:
http://mail-archives.apache.org/mod_mbox/apr-dev/201102.mbox/%3CF7B1928D-D32F-48DD-B8D9-80B26906AE51@orcaware.com%3E
. Given the importance of writing complete files for svn, could
somebody take a look and see if this is a valid issue].
I was looking at apr_file_flush() and think I found a bug where if
write() doesn't do a full write, then the apr_file_t will destroy and
buffered data because it sets its internal buffer position back to 0.
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?
Thanks,
Blair
Received on 2011-02-07 22:26:58 CET