1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-12-20 01:42:27 +03:00

Finished first cut of CRP & PosixTasks. No way it builds yet.

This commit is contained in:
Patrick LeBlanc
2019-01-29 09:52:14 -06:00
parent b38c92738c
commit 8d926202ac
13 changed files with 283 additions and 6 deletions

View File

@@ -19,6 +19,7 @@ PosixTask::PosixTask(int _sock, uint _length) :
PosixTask::~PosixTask()
{
comsumeMsg();
if (!socketReturned)
returnSocket();
}
@@ -60,11 +61,15 @@ uint PosixTask::getLength()
return totalLength;
}
// todo, need this to return an int instead of a bool b/c it modifies the length of the read
bool PosixTask::read(uint8_t *buf, uint length)
{
if (length > remainingLengthForCaller)
length = remainingLengthForCaller;
if (length == 0)
return false;
uint count = 0;
int err;
@@ -156,4 +161,24 @@ bool PosixTask::write(const vector<uint8_t> &buf)
return write(&buf[0], buf.size());
}
void PosixTask::consumeMsg()
{
uint8_t buf[1024];
int err;
bufferLen = 0;
bufferPos = 0;
remainingLengthForCaller = 0;
while (remainingLengthInStream > 0)
{
err = ::read(sock, buf, min(remainingLengthInStream, 1024));
if (err <= 0) {
remainingLengthInStream = 0;
break;
}
remainingLengthInStream -= err;
}
}
}