stream: list management cleanups

pull/2673/head
Victor Julien 9 years ago
parent 34f7cb2b55
commit bea2b2c00c

@ -583,36 +583,36 @@ int StreamTcpReassembleInsertSegment(ThreadVars *tv, TcpReassemblyThreadCtx *ra_
*/ */
static inline int SegmentInUse(TcpSession *ssn, TcpStream *stream, TcpSegment *seg) static inline bool SegmentInUse(const TcpStream *stream, const TcpSegment *seg)
{ {
/* if proto detect isn't done, we're not returning */ /* if proto detect isn't done, we're not returning */
if (!(stream->flags & (STREAMTCP_STREAM_FLAG_GAP|STREAMTCP_STREAM_FLAG_NOREASSEMBLY))) { if (!(stream->flags & (STREAMTCP_STREAM_FLAG_GAP|STREAMTCP_STREAM_FLAG_NOREASSEMBLY))) {
if (!(StreamTcpIsSetStreamFlagAppProtoDetectionCompleted(stream))) { if (!(StreamTcpIsSetStreamFlagAppProtoDetectionCompleted(stream))) {
SCReturnInt(1); SCReturnInt(true);
} }
} }
SCReturnInt(0); SCReturnInt(false);
} }
/** \internal /** \internal
* \brief check if we can remove a segment from our segment list * \brief check if we can remove a segment from our segment list
* *
* \retval 1 yes * \retval true
* \retval 0 no * \retval false
*/ */
static inline int StreamTcpReturnSegmentCheck(const Flow *f, TcpSession *ssn, TcpStream *stream, TcpSegment *seg) static inline bool StreamTcpReturnSegmentCheck(const TcpStream *stream, const TcpSegment *seg)
{ {
if (SegmentInUse(ssn, stream, seg)) { if (SegmentInUse(stream, seg)) {
SCReturnInt(0); SCReturnInt(false);
} }
if (!(StreamingBufferSegmentIsBeforeWindow(&stream->sb, &seg->sbseg))) { if (!(StreamingBufferSegmentIsBeforeWindow(&stream->sb, &seg->sbseg))) {
SCReturnInt(0); SCReturnInt(false);
} }
SCReturnInt(1); SCReturnInt(true);
} }
static inline uint64_t GetLeftEdge(TcpSession *ssn, TcpStream *stream) static inline uint64_t GetLeftEdge(TcpSession *ssn, TcpStream *stream)
@ -689,7 +689,7 @@ static inline uint64_t GetLeftEdge(TcpSession *ssn, TcpStream *stream)
break; break;
} }
if (SegmentInUse(ssn, stream, seg)) { if (SegmentInUse(stream, seg)) {
left_edge = TCP_SEG_OFFSET(seg); left_edge = TCP_SEG_OFFSET(seg);
SCLogDebug("in-use seg before left_edge, adjust to %"PRIu64" and bail", left_edge); SCLogDebug("in-use seg before left_edge, adjust to %"PRIu64" and bail", left_edge);
break; break;
@ -798,7 +798,7 @@ void StreamTcpPruneSession(Flow *f, uint8_t flags)
seg, seg->seq, TCP_SEG_LEN(seg), seg, seg->seq, TCP_SEG_LEN(seg),
(uint32_t)(seg->seq + TCP_SEG_LEN(seg)), seg->flags); (uint32_t)(seg->seq + TCP_SEG_LEN(seg)), seg->flags);
if (StreamTcpReturnSegmentCheck(f, ssn, stream, seg) == 0) { if (StreamTcpReturnSegmentCheck(stream, seg) == 0) {
SCLogDebug("not removing segment"); SCLogDebug("not removing segment");
break; break;
} }

Loading…
Cancel
Save