fix issue #502
This commit is contained in:
parent
a721d0d23e
commit
9383fc9c22
|
@ -649,23 +649,39 @@ _again:
|
||||||
|
|
||||||
// last block is at last file
|
// last block is at last file
|
||||||
if (pMeter->last) {
|
if (pMeter->last) {
|
||||||
if (pMeter->lastBlock.sversion != pObj->sversion) {
|
if ((pMeter->lastBlock.sversion != pObj->sversion) || (query.over)) {
|
||||||
// TODO : Check the correctness of this code. write the last block to
|
// TODO : Check the correctness of this code. write the last block to
|
||||||
// .data file
|
// .data file
|
||||||
pCompBlock = (SCompBlock *)(hmem + headLen);
|
pCompBlock = (SCompBlock *)(hmem + headLen);
|
||||||
assert(dmem - (char *)pCompBlock >= sizeof(SCompBlock));
|
assert(dmem - (char *)pCompBlock >= sizeof(SCompBlock));
|
||||||
*pCompBlock = pMeter->lastBlock;
|
*pCompBlock = pMeter->lastBlock;
|
||||||
pCompBlock->last = 0;
|
if (pMeter->lastBlock.sversion != pObj->sversion) {
|
||||||
pCompBlock->offset = lseek(pVnode->dfd, 0, SEEK_END);
|
pCompBlock->last = 0;
|
||||||
lseek(pVnode->lfd, pMeter->lastBlock.offset, SEEK_SET);
|
pCompBlock->offset = lseek(pVnode->dfd, 0, SEEK_END);
|
||||||
tsendfile(pVnode->dfd, pVnode->lfd, NULL, pMeter->lastBlock.len);
|
pMeter->last = 0;
|
||||||
pVnode->dfSize = pCompBlock->offset + pMeter->lastBlock.len;
|
lseek(pVnode->lfd, pMeter->lastBlock.offset, SEEK_SET);
|
||||||
|
tsendfile(pVnode->dfd, pVnode->lfd, NULL, pMeter->lastBlock.len);
|
||||||
|
pVnode->dfSize = pCompBlock->offset + pMeter->lastBlock.len;
|
||||||
|
} else {
|
||||||
|
if (ssid == 0) {
|
||||||
|
// Here, pVnode->tfd != -1
|
||||||
|
assert(pVnode->tfd != -1);
|
||||||
|
pCompBlock->offset = lseek(pVnode->tfd, 0, SEEK_END);
|
||||||
|
lseek(pVnode->lfd, pMeter->lastBlock.offset, SEEK_SET);
|
||||||
|
tsendfile(pVnode->tfd, pVnode->lfd, NULL, pMeter->lastBlock.len);
|
||||||
|
pVnode->lfSize = pCompBlock->offset + pMeter->lastBlock.len;
|
||||||
|
} else {
|
||||||
|
// Here, pVnode->tfd = -1
|
||||||
|
assert(pVnode->tfd == -1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
headLen += sizeof(SCompBlock);
|
headLen += sizeof(SCompBlock);
|
||||||
pMeter->newNumOfBlocks++;
|
pMeter->newNumOfBlocks++;
|
||||||
} else {
|
} else {
|
||||||
// read last block into memory
|
// read last block into memory
|
||||||
if (vnodeReadLastBlockToMem(pObj, &pMeter->lastBlock, data) < 0) goto _over;
|
if (vnodeReadLastBlockToMem(pObj, &pMeter->lastBlock, data) < 0) goto _over;
|
||||||
|
pMeter->last = 0;
|
||||||
pointsReadLast = pMeter->lastBlock.numOfPoints;
|
pointsReadLast = pMeter->lastBlock.numOfPoints;
|
||||||
query.over = 0;
|
query.over = 0;
|
||||||
headInfo.totalStorage -= (pointsReadLast * pObj->bytesPerPoint);
|
headInfo.totalStorage -= (pointsReadLast * pObj->bytesPerPoint);
|
||||||
|
@ -675,7 +691,6 @@ _again:
|
||||||
}
|
}
|
||||||
|
|
||||||
pMeter->changed = 1;
|
pMeter->changed = 1;
|
||||||
pMeter->last = 0;
|
|
||||||
pMeter->oldNumOfBlocks--;
|
pMeter->oldNumOfBlocks--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue