diff options
author | Stefan Fritsch <sf@apache.org> | 2011-02-21 21:23:36 +0000 |
---|---|---|
committer | Stefan Fritsch <sf@apache.org> | 2011-02-21 21:23:36 +0000 |
commit | b29726de1941ab4983da662f4874a5121553efcd (patch) | |
tree | 89e8e581cd97632569db53f6781d07d1068683cd /file_io/unix | |
parent | 7bc2340f8ea03b6a262fe11ee62f4acc60e56c37 (diff) | |
download | apr-b29726de1941ab4983da662f4874a5121553efcd.tar.gz apr-b29726de1941ab4983da662f4874a5121553efcd.zip |
apr_file_flush_locked(): Handle short writes
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1073142 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'file_io/unix')
-rw-r--r-- | file_io/unix/readwrite.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/file_io/unix/readwrite.c b/file_io/unix/readwrite.c index d736b5ea4..f12873877 100644 --- a/file_io/unix/readwrite.c +++ b/file_io/unix/readwrite.c @@ -400,12 +400,16 @@ apr_status_t apr_file_flush_locked(apr_file_t *thefile) 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; |