[td-225] update the error code when system related error happens.

This commit is contained in:
Haojun Liao 2020-06-19 11:07:10 +08:00
parent c9860ac555
commit 9c737612d5
2 changed files with 8 additions and 9 deletions

View File

@ -149,7 +149,7 @@ int16_t tExtMemBufferPut(tExtMemBuffer *pMemBuffer, void *data, int32_t numOfRow
* @param pMemBuffer * @param pMemBuffer
* @return * @return
*/ */
bool tExtMemBufferFlush(tExtMemBuffer *pMemBuffer); int32_t tExtMemBufferFlush(tExtMemBuffer *pMemBuffer);
/** /**
* *

View File

@ -245,30 +245,29 @@ static void tExtMemBufferClearFlushoutInfo(tExtMemBuffer *pMemBuffer) {
memset(pFileMeta->flushoutData.pFlushoutInfo, 0, sizeof(tFlushoutInfo) * pFileMeta->flushoutData.nAllocSize); memset(pFileMeta->flushoutData.pFlushoutInfo, 0, sizeof(tFlushoutInfo) * pFileMeta->flushoutData.nAllocSize);
} }
bool tExtMemBufferFlush(tExtMemBuffer *pMemBuffer) { int32_t tExtMemBufferFlush(tExtMemBuffer *pMemBuffer) {
int32_t ret = 0;
if (pMemBuffer->numOfTotalElems == 0) { if (pMemBuffer->numOfTotalElems == 0) {
return true; return ret;
} }
if (pMemBuffer->file == NULL) { if (pMemBuffer->file == NULL) {
if ((pMemBuffer->file = fopen(pMemBuffer->path, "wb+")) == NULL) { if ((pMemBuffer->file = fopen(pMemBuffer->path, "wb+")) == NULL) {
return false; ret = TAOS_SYSTEM_ERROR(errno);
return ret;
} }
} }
/* all data has been flushed to disk, ignore flush operation */ /* all data has been flushed to disk, ignore flush operation */
if (pMemBuffer->numOfElemsInBuffer == 0) { if (pMemBuffer->numOfElemsInBuffer == 0) {
return true; return ret;
} }
bool ret = true;
tFilePagesItem *first = pMemBuffer->pHead; tFilePagesItem *first = pMemBuffer->pHead;
while (first != NULL) { while (first != NULL) {
size_t retVal = fwrite((char *)&(first->item), pMemBuffer->pageSize, 1, pMemBuffer->file); size_t retVal = fwrite((char *)&(first->item), pMemBuffer->pageSize, 1, pMemBuffer->file);
if (retVal <= 0) { // failed to write to buffer, may be not enough space if (retVal <= 0) { // failed to write to buffer, may be not enough space
ret = false; ret = TAOS_SYSTEM_ERROR(errno);
} }
pMemBuffer->fileMeta.numOfElemsInFile += first->item.num; pMemBuffer->fileMeta.numOfElemsInFile += first->item.num;