You've already forked mariadb-columnstore-engine
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:
56
src/PosixTask.cpp
Normal file
56
src/PosixTask.cpp
Normal 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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user