• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

OISF / suricata / 22550237931

01 Mar 2026 06:56PM UTC coverage: 64.812% (-8.9%) from 73.687%
22550237931

Pull #14920

github

web-flow
Merge e05854a6d into 90823fa90
Pull Request #14920: draft: rust based configuration file parser and loader - v4

561 of 789 new or added lines in 4 files covered. (71.1%)

23225 existing lines in 498 files now uncovered.

131605 of 203055 relevant lines covered (64.81%)

2328818.84 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

76.07
/src/flow-queue.c
1
/* Copyright (C) 2007-2020 Open Information Security Foundation
2
 *
3
 * You can copy, redistribute or modify this Program under the terms of
4
 * the GNU General Public License version 2 as published by the Free
5
 * Software Foundation.
6
 *
7
 * This program is distributed in the hope that it will be useful,
8
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
 * GNU General Public License for more details.
11
 *
12
 * You should have received a copy of the GNU General Public License
13
 * version 2 along with this program; if not, write to the Free Software
14
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
15
 * 02110-1301, USA.
16
 */
17

18
/**
19
 * \file
20
 *
21
 * \author Victor Julien <victor@inliniac.net>
22
 *
23
 * Flow queue handler functions
24
 */
25

26
#include "suricata-common.h"
27
#include "threads.h"
28
#include "flow-private.h"
29
#include "flow-queue.h"
30
#include "flow-util.h"
31
#include "util-error.h"
32
#include "util-debug.h"
33
#include "util-print.h"
34

35
FlowQueue *FlowQueueNew(void)
36
{
50✔
37
    FlowQueue *q = (FlowQueue *)SCMalloc(sizeof(FlowQueue));
50✔
38
    if (q == NULL) {
50✔
39
        SCLogError("Fatal error encountered in FlowQueueNew. Exiting...");
×
40
        exit(EXIT_SUCCESS);
×
41
    }
×
42
    q = FlowQueueInit(q);
50✔
43
    return q;
50✔
44
}
50✔
45

46
FlowQueue *FlowQueueInit (FlowQueue *q)
47
{
79✔
48
    if (q != NULL) {
79✔
49
        memset(q, 0, sizeof(FlowQueue));
79✔
50
        FQLOCK_INIT(q);
79✔
51
    }
79✔
52
    return q;
79✔
53
}
79✔
54

55
/**
56
 *  \brief Destroy a flow queue
57
 *
58
 *  \param q the flow queue to destroy
59
 */
60
void FlowQueueDestroy (FlowQueue *q)
61
{
22✔
62
    FQLOCK_DESTROY(q);
22✔
63
}
22✔
64

65
void FlowQueuePrivateAppendFlow(FlowQueuePrivate *fqc, Flow *f)
66
{
299,432✔
67
    if (fqc->top == NULL) {
299,432✔
68
        fqc->top = fqc->bot = f;
12,297✔
69
        fqc->len = 1;
12,297✔
70
    } else {
287,135✔
71
        fqc->bot->next = f;
287,135✔
72
        fqc->bot = f;
287,135✔
73
        fqc->len++;
287,135✔
74
    }
287,135✔
75
    f->next = NULL;
299,432✔
76
}
299,432✔
77

78
void FlowQueuePrivatePrependFlow(FlowQueuePrivate *fqc, Flow *f)
79
{
9,418✔
80
    f->next = fqc->top;
9,418✔
81
    fqc->top = f;
9,418✔
82
    if (f->next == NULL) {
9,418✔
83
        fqc->bot = f;
7,678✔
84
    }
7,678✔
85
    fqc->len++;
9,418✔
86
}
9,418✔
87

88
void FlowQueuePrivateAppendPrivate(FlowQueuePrivate *dest, FlowQueuePrivate *src)
UNCOV
89
{
×
UNCOV
90
    if (src->top == NULL)
×
91
        return;
×
92

UNCOV
93
    if (dest->bot == NULL) {
×
UNCOV
94
        dest->top = src->top;
×
UNCOV
95
        dest->bot = src->bot;
×
UNCOV
96
        dest->len = src->len;
×
UNCOV
97
    } else {
×
UNCOV
98
        dest->bot->next = src->top;
×
UNCOV
99
        dest->bot = src->bot;
×
UNCOV
100
        dest->len += src->len;
×
UNCOV
101
    }
×
UNCOV
102
    src->top = src->bot = NULL;
×
UNCOV
103
    src->len = 0;
×
UNCOV
104
}
×
105

106
static inline void FlowQueueAtomicSetNonEmpty(FlowQueue *fq)
107
{
7✔
108
    if (!SC_ATOMIC_GET(fq->non_empty)) {
7✔
109
        SC_ATOMIC_SET(fq->non_empty, true);
7✔
110
    }
7✔
111
}
7✔
112
static inline void FlowQueueAtomicSetEmpty(FlowQueue *fq)
113
{
448✔
114
    if (SC_ATOMIC_GET(fq->non_empty)) {
448✔
115
        SC_ATOMIC_SET(fq->non_empty, false);
7✔
116
    }
7✔
117
}
448✔
118

119
void FlowQueueAppendPrivate(FlowQueue *fq, FlowQueuePrivate *fqc)
120
{
22✔
121
    if (fqc->top == NULL)
22✔
122
        return;
15✔
123

124
    FQLOCK_LOCK(fq);
7✔
125
    if (fq->qbot == NULL) {
7✔
126
        fq->qtop = fqc->top;
7✔
127
        fq->qbot = fqc->bot;
7✔
128
        fq->qlen = fqc->len;
7✔
129
    } else {
7✔
UNCOV
130
        fq->qbot->next = fqc->top;
×
UNCOV
131
        fq->qbot = fqc->bot;
×
UNCOV
132
        fq->qlen += fqc->len;
×
UNCOV
133
    }
×
134
    FlowQueueAtomicSetNonEmpty(fq);
7✔
135
    FQLOCK_UNLOCK(fq);
7✔
136
    fqc->top = fqc->bot = NULL;
7✔
137
    fqc->len = 0;
7✔
138
}
7✔
139

140
FlowQueuePrivate FlowQueueExtractPrivate(FlowQueue *fq)
141
{
426✔
142
    FQLOCK_LOCK(fq);
426✔
143
    FlowQueuePrivate fqc = fq->priv;
426✔
144
    fq->qtop = fq->qbot = NULL;
426✔
145
    fq->qlen = 0;
426✔
146
    FlowQueueAtomicSetEmpty(fq);
426✔
147
    FQLOCK_UNLOCK(fq);
426✔
148
    return fqc;
426✔
149
}
426✔
150

151
Flow *FlowQueuePrivateGetFromTop(FlowQueuePrivate *fqc)
152
{
349,418✔
153
    Flow *f = fqc->top;
349,418✔
154
    if (f == NULL) {
349,418✔
155
        return NULL;
100,568✔
156
    }
100,568✔
157

158
    fqc->top = f->next;
248,850✔
159
    f->next = NULL;
248,850✔
160
    fqc->len--;
248,850✔
161
    if (fqc->top == NULL) {
248,850✔
162
        fqc->bot = NULL;
19,375✔
163
    }
19,375✔
164
    return f;
248,850✔
165
}
349,418✔
166

167
/**
168
 *  \brief add a flow to a queue
169
 *
170
 *  \param q queue
171
 *  \param f flow
172
 */
173
void FlowEnqueue (FlowQueue *q, Flow *f)
UNCOV
174
{
×
175
#ifdef DEBUG
176
    BUG_ON(q == NULL || f == NULL);
177
#endif
UNCOV
178
    FQLOCK_LOCK(q);
×
UNCOV
179
    FlowQueuePrivateAppendFlow(&q->priv, f);
×
UNCOV
180
    FlowQueueAtomicSetNonEmpty(q);
×
UNCOV
181
    FQLOCK_UNLOCK(q);
×
UNCOV
182
}
×
183

184
/**
185
 *  \brief remove a flow from the queue
186
 *
187
 *  \param q queue
188
 *
189
 *  \retval f flow or NULL if empty list.
190
 */
191
Flow *FlowDequeue (FlowQueue *q)
192
{
22✔
193
    FQLOCK_LOCK(q);
22✔
194
    Flow *f = FlowQueuePrivateGetFromTop(&q->priv);
22✔
195
    if (f == NULL)
22✔
196
        FlowQueueAtomicSetEmpty(q);
22✔
197
    FQLOCK_UNLOCK(q);
22✔
198
    return f;
22✔
199
}
22✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc