diff --git a/source/libs/transport/inc/transComm.h b/source/libs/transport/inc/transComm.h index dabed050ec..d47ad214e8 100644 --- a/source/libs/transport/inc/transComm.h +++ b/source/libs/transport/inc/transComm.h @@ -94,10 +94,6 @@ typedef void* queue[2]; /* Return the structure holding the given element. */ #define QUEUE_DATA(e, type, field) ((type*)((void*)((char*)(e)-offsetof(type, field)))) -typedef struct { - queue q; -} queueWrapper; - // #define TRANS_RETRY_COUNT_LIMIT 100 // retry count limit // #define TRANS_RETRY_INTERVAL 15 // retry interval (ms) #define TRANS_CONN_TIMEOUT 3000 // connect timeout (ms) diff --git a/source/libs/transport/src/transCli.c b/source/libs/transport/src/transCli.c index d5ec6e7e33..72f271a1f4 100644 --- a/source/libs/transport/src/transCli.c +++ b/source/libs/transport/src/transCli.c @@ -403,16 +403,16 @@ bool filteBySeq(void* key, void* arg) { } } int32_t cliGetReqBySeq(SCliConn* conn, int32_t seq, SCliReq** pReq) { - int32_t code = 0; - queueWrapper set; - QUEUE_INIT(&set.q) + int32_t code = 0; + queue set; + QUEUE_INIT(&set) transQueueRemoveByFilter(&conn->reqsSentOut, filteBySeq, &seq, &set, 1); - if (QUEUE_IS_EMPTY(&set.q)) { + if (QUEUE_IS_EMPTY(&set)) { return TSDB_CODE_OUT_OF_RANGE; } - queue* e = QUEUE_HEAD(&set.q); + queue* e = QUEUE_HEAD(&set); SCliReq* p = QUEUE_DATA(e, SCliReq, q); *pReq = p; @@ -481,13 +481,13 @@ int32_t cliConnMayHandleState_releaseReq(SCliConn* conn, STransMsgHead* pHead) { tDebug("%s %p reqToSend:%d, sentOut:%d", CONN_GET_INST_LABEL(conn), conn, transQueueSize(&conn->reqsToSend), transQueueSize(&conn->reqsSentOut)); - queueWrapper set; - QUEUE_INIT(&set.q); + queue set; + QUEUE_INIT(&set); transQueueRemoveByFilter(&conn->reqsSentOut, filterByQid, &qId, &set, -1); transQueueRemoveByFilter(&conn->reqsToSend, filterByQid, &qId, &set, -1); - while (!QUEUE_IS_EMPTY(&set.q)) { - queue* el = QUEUE_HEAD(&set.q); + while (!QUEUE_IS_EMPTY(&set)) { + queue* el = QUEUE_HEAD(&set); SCliReq* pReq = QUEUE_DATA(el, SCliReq, q); QUEUE_REMOVE(el); if (pReq->msg.info.notFreeAhandle == 0 && pThrd != NULL && pThrd->destroyAhandleFp != NULL) { @@ -1317,12 +1317,12 @@ bool fileToRmReq(void* h, void* arg) { return false; } static void cliConnRmReqs(SCliConn* conn) { - queueWrapper set; - QUEUE_INIT(&set.q); + queue set; + QUEUE_INIT(&set); transQueueRemoveByFilter(&conn->reqsSentOut, fileToRmReq, NULL, &set, -1); - while (!QUEUE_IS_EMPTY(&set.q)) { - queue* el = QUEUE_HEAD(&set.q); + while (!QUEUE_IS_EMPTY(&set)) { + queue* el = QUEUE_HEAD(&set); QUEUE_REMOVE(el); SCliReq* pReq = QUEUE_DATA(el, SCliReq, q); destroyReq(pReq); diff --git a/source/libs/transport/src/transComm.c b/source/libs/transport/src/transComm.c index e85ce2091a..951b651ee1 100644 --- a/source/libs/transport/src/transComm.c +++ b/source/libs/transport/src/transComm.c @@ -471,14 +471,14 @@ void* transQueueGet(STransQueue* q, int idx) { } void transQueueRemoveByFilter(STransQueue* q, bool (*filter)(void* e, void* arg), void* arg, void* dst, int32_t size) { - queueWrapper* d = dst; - queue* node = QUEUE_NEXT(&q->node); + queue* d = dst; + queue* node = QUEUE_NEXT(&q->node); while (node != &q->node) { queue* next = QUEUE_NEXT(node); if (filter(node, arg)) { QUEUE_REMOVE(node); q->size--; - QUEUE_PUSH(&d->q, node); + QUEUE_PUSH(d, node); if (--size == 0) { break; }