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

Checkpointing work on CRP & posix tasks.

This commit is contained in:
Patrick LeBlanc
2019-01-28 08:05:22 -06:00
parent b23d507eaa
commit 5d894b9a77
26 changed files with 385 additions and 0 deletions

56
src/PosixTask.cpp Normal file
View File

@@ -0,0 +1,56 @@
#include "PosixTask.h"
namespace storagemanager
{
PosixTask::PosixTask(int _sock, uint _length) : sock(_sock), remainingLength(_length)
{
}
PosixTask::~PosixTask()
{
// return the socket
}
void PosixTask::handleError(int errCode)
{
char buf[80];
// TODO: construct and log a message
cout << "PosixTask caught an error reading from a socket: " << strerror_r(errCode, buf, 80) << endl;
}
/* Optimization. Make this read larger chunks into a buffer & supply data from that when possible. */
int PosixTask::read(vector<uint8_t> *buf, uint offset, uint length)
{
if (length > remainingLength)
length = remainingLength;
uint originalSize = buf->size();
buf->resize(originalSize + length);
uint count = 0;
int err;
while (count < length)
{
/* TODO: need a timeout here? */
err = ::read(sock, &(*buf)[count + offset], length - count);
if (err < 0) {
buf->resize(originalSize);
handleError(errno);
return -1;
}
else if (err == 0) {
buf->resize(originalSize);
handleError(0);
return -1;
}
count += err;
remainingLength -= err;
}
return count;
}
}