fix tqHandleDel bug
This commit is contained in:
parent
4343473243
commit
9edc17e575
|
@ -22,6 +22,9 @@
|
||||||
//
|
//
|
||||||
//handle management message
|
//handle management message
|
||||||
//
|
//
|
||||||
|
|
||||||
|
int tqGetgHandleSSize(const TqGroupHandle *gHandle);
|
||||||
|
|
||||||
static int tqProtoCheck(TmqMsgHead *pMsg) {
|
static int tqProtoCheck(TmqMsgHead *pMsg) {
|
||||||
return pMsg->protoVer == 0;
|
return pMsg->protoVer == 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,15 +27,14 @@ static int32_t tqHandlePutCommitted(TqMetaStore*, int64_t key, void* value);
|
||||||
static void* tqHandleGetUncommitted(TqMetaStore*, int64_t key);
|
static void* tqHandleGetUncommitted(TqMetaStore*, int64_t key);
|
||||||
|
|
||||||
static inline void tqLinkUnpersist(TqMetaStore *pMeta, TqMetaList* pNode) {
|
static inline void tqLinkUnpersist(TqMetaStore *pMeta, TqMetaList* pNode) {
|
||||||
if(pNode->unpersistNext == NULL) {
|
if(pNode->unpersistNext == NULL) {
|
||||||
pNode->unpersistNext = pMeta->unpersistHead->unpersistNext;
|
pNode->unpersistNext = pMeta->unpersistHead->unpersistNext;
|
||||||
pNode->unpersistPrev = pMeta->unpersistHead;
|
pNode->unpersistPrev = pMeta->unpersistHead;
|
||||||
pMeta->unpersistHead->unpersistNext->unpersistPrev = pNode;
|
pMeta->unpersistHead->unpersistNext->unpersistPrev = pNode;
|
||||||
pMeta->unpersistHead->unpersistNext = pNode;
|
pMeta->unpersistHead->unpersistNext = pNode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
typedef struct TqMetaPageBuf {
|
typedef struct TqMetaPageBuf {
|
||||||
int16_t offset;
|
int16_t offset;
|
||||||
char buffer[TQ_PAGE_SIZE];
|
char buffer[TQ_PAGE_SIZE];
|
||||||
|
@ -401,7 +400,7 @@ void* tqHandleGet(TqMetaStore* pMeta, int64_t key) {
|
||||||
TqMetaList* pNode = pMeta->bucket[bucketKey];
|
TqMetaList* pNode = pMeta->bucket[bucketKey];
|
||||||
while(pNode) {
|
while(pNode) {
|
||||||
if(pNode->handle.key == key) {
|
if(pNode->handle.key == key) {
|
||||||
if(pNode->handle.valueInUse != NULL) {
|
if(pNode->handle.valueInUse != NULL && pNode->handle.valueInUse != TQ_DELETE_TOKEN) {
|
||||||
return pNode->handle.valueInUse;
|
return pNode->handle.valueInUse;
|
||||||
} else {
|
} else {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -546,9 +545,10 @@ int32_t tqHandleDel(TqMetaStore* pMeta, int64_t key) {
|
||||||
int64_t bucketKey = key & TQ_BUCKET_SIZE;
|
int64_t bucketKey = key & TQ_BUCKET_SIZE;
|
||||||
TqMetaList* pNode = pMeta->bucket[bucketKey];
|
TqMetaList* pNode = pMeta->bucket[bucketKey];
|
||||||
while(pNode) {
|
while(pNode) {
|
||||||
if(pNode->handle.valueInTxn
|
if(pNode->handle.valueInTxn != TQ_DELETE_TOKEN) {
|
||||||
&& pNode->handle.valueInTxn != TQ_DELETE_TOKEN) {
|
if(pNode->handle.valueInTxn) {
|
||||||
pMeta->deleter(pNode->handle.valueInTxn);
|
pMeta->deleter(pNode->handle.valueInTxn);
|
||||||
|
}
|
||||||
pNode->handle.valueInTxn = TQ_DELETE_TOKEN;
|
pNode->handle.valueInTxn = TQ_DELETE_TOKEN;
|
||||||
tqLinkUnpersist(pMeta, pNode);
|
tqLinkUnpersist(pMeta, pNode);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -130,4 +130,11 @@ TEST_F(TqMetaTest, deleteTest) {
|
||||||
tqHandleCommit(pMeta, 1);
|
tqHandleCommit(pMeta, 1);
|
||||||
pFoo = (Foo*) tqHandleGet(pMeta, 1);
|
pFoo = (Foo*) tqHandleGet(pMeta, 1);
|
||||||
EXPECT_EQ(pFoo == NULL, true);
|
EXPECT_EQ(pFoo == NULL, true);
|
||||||
|
|
||||||
|
tqStoreClose(pMeta);
|
||||||
|
pMeta = tqStoreOpen(pathName,
|
||||||
|
FooSerializer, FooDeserializer, FooDeleter);
|
||||||
|
ASSERT(pMeta);
|
||||||
|
pFoo = (Foo*) tqHandleGet(pMeta, 1);
|
||||||
|
EXPECT_EQ(pFoo == NULL, true);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue