From 12b560e6db7f7c8698d210d28e7445cc75a5038a Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Mon, 16 Sep 2024 17:33:03 +0800 Subject: [PATCH] Merge branch '3.0' into enh/opt-transport --- source/libs/transport/src/transCli.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/source/libs/transport/src/transCli.c b/source/libs/transport/src/transCli.c index 3e47908a86..7e3ca86b6e 100644 --- a/source/libs/transport/src/transCli.c +++ b/source/libs/transport/src/transCli.c @@ -371,18 +371,20 @@ void cliConnMayUpdateTimer(SCliConn* conn, int timeout) { if (pInst->startReadTimer == 0) { return; } + // reset previous timer if (conn->timer != NULL) { // reset previous timer cliResetConnTimer(conn); } int32_t reqsSentNum = transQueueSize(&conn->reqsSentOut); if (reqsSentNum == 0) { + // no need to set timer return; } - if (conn->timer == NULL) { - if (cliGetConnTimer(conn->hostThrd, conn) != 0) { - return; - } + + // start a new timer + if (cliGetConnTimer(conn->hostThrd, conn) != 0) { + return; } uv_timer_start(conn->timer, cliConnTimeout__checkReq, timeout, 0); }