From db3bea8f38bf1877aa16b6f3887f3991a7567e25 Mon Sep 17 00:00:00 2001 From: slguan Date: Tue, 24 Mar 2020 23:13:02 +0800 Subject: [PATCH] [TD-10] fix memery corrupt after tqueue changed --- src/dnode/src/dnodeMgmt.c | 16 ++++++++-------- src/dnode/src/dnodeRead.c | 14 +++++++++----- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/dnode/src/dnodeMgmt.c b/src/dnode/src/dnodeMgmt.c index f6976aa2cc..4d335d7353 100644 --- a/src/dnode/src/dnodeMgmt.c +++ b/src/dnode/src/dnodeMgmt.c @@ -225,17 +225,17 @@ static int32_t dnodeOpenVnode(int32_t vnode, char *rootDir) { vnodeObj.status = TSDB_VN_STATUS_NOT_READY; vnodeObj.refCount = 1; vnodeObj.version = 0; - vnodeObj.wworker = dnodeAllocateWriteWorker(&vnodeObj); - vnodeObj.rworker = dnodeAllocateReadWorker(&vnodeObj); vnodeObj.wal = NULL; vnodeObj.tsdb = pTsdb; vnodeObj.replica = NULL; vnodeObj.events = NULL; vnodeObj.cq = NULL; - taosAddIntHash(tsDnodeVnodesHash, vnodeObj.vgId, (char *) (&vnodeObj)); + SVnodeObj *pVnode = (SVnodeObj *)taosAddIntHash(tsDnodeVnodesHash, vnodeObj.vgId, (char *)(&vnodeObj)); + pVnode->wworker = dnodeAllocateWriteWorker(pVnode); + pVnode->rworker = dnodeAllocateReadWorker(pVnode); - dTrace("open vnode:%d in %s", vnodeObj.vgId, rootDir); + dTrace("open vnode:%d in %s", pVnode->vgId, rootDir); return TSDB_CODE_SUCCESS; } @@ -314,17 +314,17 @@ static int32_t dnodeCreateVnode(SMDCreateVnodeMsg *pVnodeCfg) { vnodeObj.status = TSDB_VN_STATUS_NOT_READY; vnodeObj.refCount = 1; vnodeObj.version = 0; - vnodeObj.wworker = dnodeAllocateWriteWorker(&vnodeObj); - vnodeObj.rworker = dnodeAllocateReadWorker(&vnodeObj); vnodeObj.wal = NULL; vnodeObj.tsdb = pTsdb; vnodeObj.replica = NULL; vnodeObj.events = NULL; vnodeObj.cq = NULL; - taosAddIntHash(tsDnodeVnodesHash, vnodeObj.vgId, (char *) (&vnodeObj)); + SVnodeObj *pVnode = (SVnodeObj *)taosAddIntHash(tsDnodeVnodesHash, vnodeObj.vgId, (char *)(&vnodeObj)); + pVnode->wworker = dnodeAllocateWriteWorker(pVnode); + pVnode->rworker = dnodeAllocateReadWorker(pVnode); - dPrint("vgroup:%d, vnode:%d is created", vnodeObj.vgId, vnodeObj.vgId); + dPrint("vgroup:%d, vnode:%d is created", pVnode->vgId, pVnode->vgId); return TSDB_CODE_SUCCESS; } diff --git a/src/dnode/src/dnodeRead.c b/src/dnode/src/dnodeRead.c index c928f5ee91..d6ecf2fa66 100644 --- a/src/dnode/src/dnodeRead.c +++ b/src/dnode/src/dnodeRead.c @@ -220,11 +220,15 @@ static void dnodeProcessReadResult(void *pVnode, SReadMsg *pRead) { code = terrno; } - SRpcMsg rsp; - rsp.handle = pRead->rpcMsg.handle; - rsp.code = code; - rsp.pCont = NULL; - rpcSendResponse(&rsp); + //TODO: query handle is returned by dnodeProcessQueryMsg + if (0) { + SRpcMsg rsp; + rsp.handle = pRead->rpcMsg.handle; + rsp.code = code; + rsp.pCont = NULL; + rpcSendResponse(&rsp); + } + rpcFreeCont(pRead->rpcMsg.pCont); // free the received message } -- GitLab