From 3aea0bd4f38ff5ad6b220a2c4ee0b9e65a8b166e Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Wed, 13 Apr 2016 10:13:50 +0200 Subject: [PATCH] stream-tcp: introduce stream cleanup function --- src/stream-tcp.c | 15 ++++++++++----- src/stream-tcp.h | 3 +++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/stream-tcp.c b/src/stream-tcp.c index a7619e5dbd..f17a761369 100644 --- a/src/stream-tcp.c +++ b/src/stream-tcp.c @@ -165,6 +165,14 @@ int StreamTcpCheckMemcap(uint64_t size) return 0; } +void StreamTcpStreamCleanup(TcpStream *stream) +{ + if (stream != NULL) { + StreamTcpSackFreeList(stream); + StreamTcpReturnStreamSegments(stream); + } +} + /** * \brief Session cleanup function. Does not free the ssn. * \param ssn tcp session @@ -179,11 +187,8 @@ void StreamTcpSessionCleanup(TcpSession *ssn) if (ssn == NULL) return; - StreamTcpSackFreeList(&ssn->client); - StreamTcpSackFreeList(&ssn->server); - - StreamTcpReturnStreamSegments(&ssn->client); - StreamTcpReturnStreamSegments(&ssn->server); + StreamTcpStreamCleanup(&ssn->client); + StreamTcpStreamCleanup(&ssn->server); /* if we have (a) smsg(s), return to the pool */ smsg = ssn->toserver_smsg_head; diff --git a/src/stream-tcp.h b/src/stream-tcp.h index dc3ccbf676..416cd5aa80 100644 --- a/src/stream-tcp.h +++ b/src/stream-tcp.h @@ -229,6 +229,9 @@ int StreamTcpPacket (ThreadVars *tv, Packet *p, StreamTcpThread *stt, void StreamTcpSessionClear(void *ssnptr); /* cleanup ssn, but don't free ssn */ void StreamTcpSessionCleanup(TcpSession *ssn); +/* cleanup stream, but don't free the stream */ +void StreamTcpStreamCleanup(TcpStream *stream); + uint32_t StreamTcpGetStreamSize(TcpStream *stream);