1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-12-17 01:02:23 +03:00

Phase 1 of trying to clean up some messaging code.

This commit is contained in:
Patrick LeBlanc
2019-02-11 18:08:18 -06:00
parent d792f78c25
commit b78cac755b
16 changed files with 123 additions and 104 deletions

View File

@@ -46,12 +46,11 @@ bool ReadTask::run()
// read from IOC, write to the socket
vector<uint8_t> outbuf;
outbuf.resize(max(cmd->count, 4) + sizeof(sm_msg_resp));
sm_msg_resp *resp = (sm_msg_resp *) &outbuf[0];
outbuf.resize(max(cmd->count, 4) + sizeof(sm_response));
sm_response *resp = (sm_response *) &outbuf[0];
resp->type = SM_MSG_START;
resp->returnCode = 0;
resp->payloadLen = 4;
uint payloadLen = 0;
// todo: do the reading and writing in chunks
// todo: need to make this use O_DIRECT on the IOC side
@@ -63,8 +62,8 @@ bool ReadTask::run()
cmd->count - resp->returnCode);
if (err < 0) {
if (resp->returnCode == 0) {
resp->payloadLen = 8;
resp->returnCode = err;
payloadLen = 4;
*((int32_t *) resp->payload) = errno;
}
break;
@@ -72,10 +71,10 @@ bool ReadTask::run()
if (err == 0)
break;
resp->returnCode += err;
resp->payloadLen += err;
}
success = write(&outbuf[0], resp->payloadLen + SM_HEADER_LEN);
if (resp->returnCode >= 0)
payloadLen = resp->returnCode;
success = write(*resp, payloadLen);
return success;
}