From 8882fed6672ec85aa8721281a0dfe28fb685cae5 Mon Sep 17 00:00:00 2001 From: jtao1735 Date: Wed, 6 May 2020 15:15:39 +0000 Subject: [PATCH] optimize the tqueue code for rpc, set the link as secured for success response before sending response --- src/rpc/src/rpcMain.c | 1 + src/util/src/tqueue.c | 10 +++------- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/rpc/src/rpcMain.c b/src/rpc/src/rpcMain.c index 3e4e05cd11..20404511f6 100644 --- a/src/rpc/src/rpcMain.c +++ b/src/rpc/src/rpcMain.c @@ -1083,6 +1083,7 @@ static void rpcSendMsgToPeer(SRpcConn *pConn, void *msg, int msgLen) { pRpc->label, pConn, taosMsg[pHead->msgType], pConn->peerFqdn, pConn->peerPort, msgLen, pHead->sourceId, pHead->destId, pHead->tranId); } else { + if (pHead->code == 0) pConn->secured = 1; // for success response, set link as secured if (pHead->msgType < TSDB_MSG_TYPE_CM_HEARTBEAT || (rpcDebugFlag & 16)) tTrace( "%s %p, %s is sent to %s:%hu, code:0x%x len:%d sig:0x%08x:0x%08x:%d", pRpc->label, pConn, taosMsg[pHead->msgType], pConn->peerFqdn, pConn->peerPort, diff --git a/src/util/src/tqueue.c b/src/util/src/tqueue.c index a458cefc9c..8a203ed917 100644 --- a/src/util/src/tqueue.c +++ b/src/util/src/tqueue.c @@ -94,8 +94,6 @@ void *taosAllocateQitem(int size) { void taosFreeQitem(void *param) { if (param == NULL) return; - uTrace("item:%p is freed", param); - char *temp = (char *)param; temp -= sizeof(STaosQnode); free(temp); @@ -144,7 +142,7 @@ int taosReadQitem(taos_queue param, int *type, void **pitem) { queue->numOfItems--; if (queue->qset) atomic_sub_fetch_32(&queue->qset->numOfItems, 1); code = 1; - //uTrace("item:%p is read out from queue, items:%d", *pitem, queue->numOfItems); + uTrace("item:%p is read out from queue, items:%d", *pitem, queue->numOfItems); } pthread_mutex_unlock(&queue->mutex); @@ -309,13 +307,12 @@ int taosReadQitemFromQset(taos_qset param, int *type, void **pitem, void **phand pthread_mutex_lock(&qset->mutex); for(int i=0; inumOfQueues; ++i) { - //pthread_mutex_lock(&qset->mutex); if (qset->current == NULL) qset->current = qset->head; STaosQueue *queue = qset->current; if (queue) qset->current = queue->next; - //pthread_mutex_unlock(&qset->mutex); if (queue == NULL) break; + if (queue->head == NULL) continue; pthread_mutex_lock(&queue->mutex); @@ -351,13 +348,12 @@ int taosReadAllQitemsFromQset(taos_qset param, taos_qall p2, void **phandle) { pthread_mutex_lock(&qset->mutex); for(int i=0; inumOfQueues; ++i) { - // pthread_mutex_lock(&qset->mutex); if (qset->current == NULL) qset->current = qset->head; queue = qset->current; if (queue) qset->current = queue->next; - // pthread_mutex_unlock(&qset->mutex); if (queue == NULL) break; + if (queue->head == NULL) continue; pthread_mutex_lock(&queue->mutex); -- GitLab