Better write handling

This commit is contained in:
lganzzzo 2018-09-14 18:37:55 +03:00
parent f1d4270fe8
commit b0f0013a93

View File

@ -53,7 +53,17 @@ public:
}
void writeToStream(const std::shared_ptr<OutputStream>& stream) override {
stream->write(m_buffer);
oatpp::os::io::Library::v_size progress = 0;
while (progress < m_buffer->getSize()) {
auto res = stream->write(&m_buffer->getData()[progress], m_buffer->getSize() - progress);
if(res < 0) {
if(res == oatpp::data::stream::IOStream::ERROR_IO_PIPE ||
(res != oatpp::data::stream::IOStream::ERROR_IO_RETRY && res != oatpp::data::stream::IOStream::ERROR_IO_WAIT_RETRY)) {
return;
}
}
progress += res;
}
}
public: