From 66ddbc3a8b02f40e32cadbb89983f96868d19602 Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Thu, 9 Feb 2023 16:35:53 +0100 Subject: [PATCH] stream: move state queue code into util func (cherry picked from commit 288086af3feb40318784b5fa1e92d73c11081481) --- src/stream-tcp.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/stream-tcp.c b/src/stream-tcp.c index 859e9d408f..d2ab48924a 100644 --- a/src/stream-tcp.c +++ b/src/stream-tcp.c @@ -211,6 +211,20 @@ void StreamTcpStreamCleanup(TcpStream *stream) } } +static void StreamTcp3wsFreeQueue(TcpSession *ssn) +{ + TcpStateQueue *q, *q_next; + q = ssn->queue; + while (q != NULL) { + q_next = q->next; + SCFree(q); + q = q_next; + StreamTcpDecrMemuse((uint64_t)sizeof(TcpStateQueue)); + } + ssn->queue = NULL; + ssn->queue_len = 0; +} + /** * \brief Session cleanup function. Does not free the ssn. * \param ssn tcp session @@ -218,23 +232,13 @@ void StreamTcpStreamCleanup(TcpStream *stream) void StreamTcpSessionCleanup(TcpSession *ssn) { SCEnter(); - TcpStateQueue *q, *q_next; if (ssn == NULL) return; StreamTcpStreamCleanup(&ssn->client); StreamTcpStreamCleanup(&ssn->server); - - q = ssn->queue; - while (q != NULL) { - q_next = q->next; - SCFree(q); - q = q_next; - StreamTcpDecrMemuse((uint64_t)sizeof(TcpStateQueue)); - } - ssn->queue = NULL; - ssn->queue_len = 0; + StreamTcp3wsFreeQueue(ssn); SCReturn; } -- 2.47.2