提交 b528cb05 编写于 作者: C cademfly

fix dup hash

上级 824c87a6
...@@ -400,6 +400,32 @@ static int32_t mndUserActionInsert(SSdb *pSdb, SUserObj *pUser) { ...@@ -400,6 +400,32 @@ static int32_t mndUserActionInsert(SSdb *pSdb, SUserObj *pUser) {
return 0; return 0;
} }
SHashObj *mndDupTableHash(SHashObj *pOld) {
SHashObj *pNew =
taosHashInit(taosHashGetSize(pOld), taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_ENTRY_LOCK);
if (pNew == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
return NULL;
}
char *tb = taosHashIterate(pOld, NULL);
while (tb != NULL) {
size_t keyLen = 0;
char *key = taosHashGetKey(tb, &keyLen);
int32_t valueLen = strlen(tb) + 1;
if (taosHashPut(pNew, key, keyLen, tb, valueLen) != 0) {
taosHashCancelIterate(pOld, tb);
taosHashCleanup(pNew);
terrno = TSDB_CODE_OUT_OF_MEMORY;
return NULL;
}
tb = taosHashIterate(pOld, tb);
}
return pNew;
}
static int32_t mndUserDupObj(SUserObj *pUser, SUserObj *pNew) { static int32_t mndUserDupObj(SUserObj *pUser, SUserObj *pNew) {
memcpy(pNew, pUser, sizeof(SUserObj)); memcpy(pNew, pUser, sizeof(SUserObj));
pNew->authVersion++; pNew->authVersion++;
...@@ -408,8 +434,8 @@ static int32_t mndUserDupObj(SUserObj *pUser, SUserObj *pNew) { ...@@ -408,8 +434,8 @@ static int32_t mndUserDupObj(SUserObj *pUser, SUserObj *pNew) {
taosRLockLatch(&pUser->lock); taosRLockLatch(&pUser->lock);
pNew->readDbs = mndDupDbHash(pUser->readDbs); pNew->readDbs = mndDupDbHash(pUser->readDbs);
pNew->writeDbs = mndDupDbHash(pUser->writeDbs); pNew->writeDbs = mndDupDbHash(pUser->writeDbs);
pNew->readTbs = mndDupTopicHash(pUser->readTbs); pNew->readTbs = mndDupTableHash(pUser->readTbs);
pNew->writeTbs = mndDupTopicHash(pUser->writeTbs); pNew->writeTbs = mndDupTableHash(pUser->writeTbs);
pNew->topics = mndDupTopicHash(pUser->topics); pNew->topics = mndDupTopicHash(pUser->topics);
taosRUnLockLatch(&pUser->lock); taosRUnLockLatch(&pUser->lock);
...@@ -826,7 +852,8 @@ static int32_t mndProcessAlterUserReq(SRpcMsg *pReq) { ...@@ -826,7 +852,8 @@ static int32_t mndProcessAlterUserReq(SRpcMsg *pReq) {
if (pStb == NULL) { if (pStb == NULL) {
mndReleaseStb(pMnode, pStb); mndReleaseStb(pMnode, pStb);
goto _OVER; goto _OVER;
} }
if (taosHashRemove(newUser.readTbs, tbFName, len) != 0) { if (taosHashRemove(newUser.readTbs, tbFName, len) != 0) {
mndReleaseStb(pMnode, pStb); mndReleaseStb(pMnode, pStb);
goto _OVER; goto _OVER;
...@@ -912,7 +939,7 @@ static int32_t mndProcessAlterUserReq(SRpcMsg *pReq) { ...@@ -912,7 +939,7 @@ static int32_t mndProcessAlterUserReq(SRpcMsg *pReq) {
goto _OVER; goto _OVER;
} }
int32_t condLen = strlen(alterReq.tagCond) + 1; int32_t condLen = alterReq.tagCondLen + 1;
if (taosHashPut(newUser.readTbs, tbFName, len, alterReq.tagCond, condLen) != 0) { if (taosHashPut(newUser.readTbs, tbFName, len, alterReq.tagCond, condLen) != 0) {
mndReleaseStb(pMnode, pStb); mndReleaseStb(pMnode, pStb);
goto _OVER; goto _OVER;
...@@ -933,7 +960,7 @@ static int32_t mndProcessAlterUserReq(SRpcMsg *pReq) { ...@@ -933,7 +960,7 @@ static int32_t mndProcessAlterUserReq(SRpcMsg *pReq) {
mndReleaseStb(pMnode, pStb); mndReleaseStb(pMnode, pStb);
goto _OVER; goto _OVER;
} }
int32_t condLen = strlen(alterReq.tagCond) + 1; int32_t condLen = alterReq.tagCondLen + 1;
if (taosHashPut(newUser.writeTbs, tbFName, len, alterReq.tagCond, condLen) != 0) { if (taosHashPut(newUser.writeTbs, tbFName, len, alterReq.tagCond, condLen) != 0) {
mndReleaseStb(pMnode, pStb); mndReleaseStb(pMnode, pStb);
goto _OVER; goto _OVER;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册