summaryrefslogtreecommitdiff
path: root/file_io
diff options
context:
space:
mode:
authorjorton <jorton@13f79535-47bb-0310-9956-ffa450edef68>2005-09-02 12:22:45 +0000
committerjorton <jorton@13f79535-47bb-0310-9956-ffa450edef68>2005-09-02 12:22:45 +0000
commit28210842c85a1a5233644986853a2e38a35ddfd9 (patch)
tree33f82c4b66e3a42cf84beb461960d62b7b198cfa /file_io
parentcdfea91bd910da2acc98a1bb603c8b751f23d415 (diff)
downloadlibapr-28210842c85a1a5233644986853a2e38a35ddfd9.tar.gz
Merge r234013, r239221 from trunk:
* file_io/unix/readwrite.c (apr_file_write): Catch apr_file_flush() failure for buffered files. (apr_file_read): Handle the apr_file_flush() return value when flushing buffered writes. * test/testfile.c (test_fail_write_flush, test_fail_read_flush): Add test cases. Submitted by: Erik Huelsmann <ehuels gmail.com>, jorton git-svn-id: http://svn.apache.org/repos/asf/apr/apr/branches/0.9.x@267192 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'file_io')
-rw-r--r--file_io/unix/readwrite.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/file_io/unix/readwrite.c b/file_io/unix/readwrite.c
index 5e163ec7a..2b9deacf9 100644
--- a/file_io/unix/readwrite.c
+++ b/file_io/unix/readwrite.c
@@ -50,7 +50,15 @@ APR_DECLARE(apr_status_t) apr_file_read(apr_file_t *thefile, void *buf, apr_size
#endif
if (thefile->direction == 1) {
- apr_file_flush(thefile);
+ rv = apr_file_flush(thefile);
+ if (rv) {
+#if APR_HAS_THREADS
+ if (thefile->thlock) {
+ apr_thread_mutex_unlock(thefile->thlock);
+ }
+#endif
+ return rv;
+ }
thefile->bufpos = 0;
thefile->direction = 0;
thefile->dataRead = 0;
@@ -173,7 +181,7 @@ APR_DECLARE(apr_status_t) apr_file_write(apr_file_t *thefile, const void *buf, a
rv = 0;
while (rv == 0 && size > 0) {
if (thefile->bufpos == APR_FILE_BUFSIZE) /* write buffer is full*/
- apr_file_flush(thefile);
+ rv = apr_file_flush(thefile);
blocksize = size > APR_FILE_BUFSIZE - thefile->bufpos ?
APR_FILE_BUFSIZE - thefile->bufpos : size;