From: Victor Julien Date: Wed, 13 Apr 2016 08:13:50 +0000 (+0200) Subject: stream-tcp: introduce stream cleanup function X-Git-Tag: suricata-3.1RC1~247 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3aea0bd4f38ff5ad6b220a2c4ee0b9e65a8b166e;p=thirdparty%2Fsuricata.git stream-tcp: introduce stream cleanup function --- 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);