data::stream: make transferAsync() method consistent with simple API.

This commit is contained in:
lganzzzo 2021-10-07 02:30:54 +03:00
parent 08b02340c9
commit 7f5576f52e
2 changed files with 12 additions and 5 deletions

View File

@ -727,7 +727,11 @@ async::CoroutineStarter transferAsync(const base::ObjectHandle<ReadCallback>& re
switch(res) {
case IOError::BROKEN_PIPE:
return error<AsyncTransferError>("[oatpp::data::stream::transferAsync]: Error. ReadCallback. BROKEN_PIPE.");
if(m_transferSize > 0) {
return error<AsyncTransferError>("[oatpp::data::stream::transferAsync]: Error. ReadCallback. BROKEN_PIPE.");
}
m_inData.set(nullptr, 0);
break;
case IOError::ZERO_VALUE:
m_inData.set(nullptr, 0);
@ -746,10 +750,13 @@ async::CoroutineStarter transferAsync(const base::ObjectHandle<ReadCallback>& re
return repeat();
default:
if(!action.isNone()) {
return action;
if(m_transferSize > 0) {
if (!action.isNone()) {
return action;
}
return error<AsyncTransferError>("[oatpp::data::stream::transferAsync]: Error. ReadCallback. Unknown IO error.");
}
return error<AsyncTransferError>("[oatpp::data::stream::transferAsync]: Error. ReadCallback. Unknown IO error.");
m_inData.set(nullptr, 0);
}

View File

@ -46,7 +46,7 @@ class ReadCallback : public oatpp::data::stream::ReadCallback {
public:
v_io_size read(void *buffer, v_buff_size count, async::Action &action) override {
OATPP_LOGE("TEST", "read(...)")
OATPP_LOGI("TEST", "read(...)")
std::this_thread::sleep_for(std::chrono::milliseconds(100));
char* data = (char*) buffer;
data[0] = 'A';