1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-30 19:23:07 +03:00

Change posixtask::read to return int instead of bool and handle when data read is short of expected message length.

This commit is contained in:
benthompson15
2019-09-16 16:26:42 -05:00
parent 99399d289f
commit 021009fe99
10 changed files with 27 additions and 23 deletions

View File

@ -36,7 +36,7 @@ WriteTask::~WriteTask()
}
#define check_error(msg, ret) \
if (!success) \
if (success<0) \
{ \
handleError(msg, errno); \
return ret; \
@ -47,7 +47,7 @@ WriteTask::~WriteTask()
bool WriteTask::run()
{
SMLogging* logger = SMLogging::get();
bool success;
int success;
uint8_t cmdbuf[1024] = {0};
success = read(cmdbuf, sizeof(write_cmd));
@ -77,14 +77,16 @@ bool WriteTask::run()
uint toRead = min(cmd->count - readCount, bufsize);
success = read(&databuf[0], toRead);
check_error("WriteTask read data", false);
readCount += toRead;
if (success==0)
break;
readCount += success;
uint writePos = 0;
ssize_t err;
while (writeCount < readCount)
{
try
{
err = ioc->write(cmd->filename, &databuf[writePos], cmd->offset + writeCount, toRead - writePos);
err = ioc->write(cmd->filename, &databuf[writePos], cmd->offset + writeCount, success - writePos);
}
catch (exception &e)
{
@ -113,8 +115,7 @@ bool WriteTask::run()
}
else
resp->returnCode = writeCount;
success = write(*resp, payloadLen);
return success;
return write(*resp, payloadLen);
}
}