From 59c59362f3819c6cb1b666a37ee9c8c34a755e94 Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Wed, 6 Dec 2023 13:52:45 +0800 Subject: [PATCH] add http fast quit --- source/libs/transport/src/thttp.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/source/libs/transport/src/thttp.c b/source/libs/transport/src/thttp.c index bbfccf9f70..b36731ab0b 100644 --- a/source/libs/transport/src/thttp.c +++ b/source/libs/transport/src/thttp.c @@ -194,18 +194,21 @@ static void httpDestroyMsg(SHttpMsg* msg) { static void httpMayDiscardMsg(SHttpModule* http, SAsyncItem* item) { SHttpMsg *msg = NULL, *quitMsg = NULL; - int8_t quit = atomic_load_8(&http->quit); - if (quit == 1) { - while (!QUEUE_IS_EMPTY(&item->qmsg)) { - queue* h = QUEUE_HEAD(&item->qmsg); - QUEUE_REMOVE(h); - msg = QUEUE_DATA(h, SHttpMsg, q); - if (!msg->quit) { - httpDestroyMsg(msg); - } else { - quitMsg = msg; - } + if (atomic_load_8(&http->quit) == 0) { + return; + } + + while (!QUEUE_IS_EMPTY(&item->qmsg)) { + queue* h = QUEUE_HEAD(&item->qmsg); + QUEUE_REMOVE(h); + msg = QUEUE_DATA(h, SHttpMsg, q); + if (!msg->quit) { + httpDestroyMsg(msg); + } else { + quitMsg = msg; } + } + if (quitMsg != NULL) { QUEUE_PUSH(&item->qmsg, &quitMsg->q); } }