aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Richard <[email protected]>2009-06-21 21:07:35 +0000
committerVincent Richard <[email protected]>2009-06-21 21:07:35 +0000
commit9bd54d3e470f293eab504f7ac0f5efbbd3affc43 (patch)
tree1498df475b24111fc609e9e612831650d61cc0fc
parentAdded other missing return error checks for posix system calls; check consist... (diff)
downloadvmime-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.cpp25
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;
+ }
}