diff options
author | Vincent Richard <[email protected]> | 2009-06-21 21:07:35 +0000 |
---|---|---|
committer | Vincent Richard <[email protected]> | 2009-06-21 21:07:35 +0000 |
commit | 9bd54d3e470f293eab504f7ac0f5efbbd3affc43 (patch) | |
tree | 1498df475b24111fc609e9e612831650d61cc0fc | |
parent | Added other missing return error checks for posix system calls; check consist... (diff) | |
download | vmime-9bd54d3e470f293eab504f7ac0f5efbbd3affc43.tar.gz vmime-9bd54d3e470f293eab504f7ac0f5efbbd3affc43.zip |
Changed posix write wrapper since a) write can be interrupted and b) write can write less than specified without error (Georg Sauthoff).
-rw-r--r-- | src/platforms/posix/posixFile.cpp | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/src/platforms/posix/posixFile.cpp b/src/platforms/posix/posixFile.cpp index 79da3515..9b16d035 100644 --- a/src/platforms/posix/posixFile.cpp +++ b/src/platforms/posix/posixFile.cpp @@ -127,8 +127,29 @@ posixFileWriterOutputStream::~posixFileWriterOutputStream() void posixFileWriterOutputStream::write(const value_type* const data, const size_type count) { - if (::write(m_fd, data, count) == -1) - posixFileSystemFactory::reportError(m_path, errno); + const value_type* array = data; + size_t size = count; + + while (1) + { + ssize_t ret = ::write(m_fd, array, size); + + if (ret == -1) + { + if (errno == EINTR) + continue; + + posixFileSystemFactory::reportError(m_path, errno); + break; + } + else if (size_t(ret) < size) + { + array += ret; + size -= ret; + } + + break; + } } |