[td-225] update the error code when system related error happens.
This commit is contained in:
parent
c9860ac555
commit
9c737612d5
|
@ -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);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
|
@ -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;
|
||||||
|
|
Loading…
Reference in New Issue