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

OISF / suricata / 23374838686

21 Mar 2026 07:29AM UTC coverage: 59.341% (-20.0%) from 79.315%
23374838686

Pull #15075

github

web-flow
Merge 90b4e834f into 6587e363a
Pull Request #15075: Stack 8001 v16.4

38 of 70 new or added lines in 10 files covered. (54.29%)

34165 existing lines in 563 files now uncovered.

119621 of 201584 relevant lines covered (59.34%)

650666.92 hits per line

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

0.0
/src/tm-queues.c
1
/* Copyright (C) 2007-2019 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
 * Thread module management functions
24
 */
25

26
#include "suricata.h"
27
#include "threads.h"
28
#include "tm-queues.h"
29
#include "util-debug.h"
30

31
static TAILQ_HEAD(TmqList_, Tmq_) tmq_list = TAILQ_HEAD_INITIALIZER(tmq_list);
32

33
static uint16_t tmq_id = 0;
34

35
Tmq *TmqCreateQueue(const char *name)
UNCOV
36
{
×
UNCOV
37
    Tmq *q = SCCalloc(1, sizeof(*q));
×
UNCOV
38
    if (q == NULL)
×
39
        FatalError("SCCalloc failed");
×
40

UNCOV
41
    q->name = SCStrdup(name);
×
UNCOV
42
    if (q->name == NULL)
×
43
        FatalError("SCStrdup failed");
×
44

UNCOV
45
    q->id = tmq_id++;
×
UNCOV
46
    q->is_packet_pool = (strcmp(q->name, "packetpool") == 0);
×
UNCOV
47
    if (!q->is_packet_pool) {
×
UNCOV
48
        q->pq = PacketQueueAlloc();
×
UNCOV
49
        if (q->pq == NULL)
×
50
            FatalError("PacketQueueAlloc failed");
×
UNCOV
51
    }
×
52

UNCOV
53
    TAILQ_INSERT_HEAD(&tmq_list, q, next);
×
54

UNCOV
55
    SCLogDebug("created queue \'%s\', %p", name, q);
×
UNCOV
56
    return q;
×
UNCOV
57
}
×
58

59
Tmq *TmqGetQueueByName(const char *name)
UNCOV
60
{
×
UNCOV
61
    Tmq *tmq = NULL;
×
UNCOV
62
    TAILQ_FOREACH(tmq, &tmq_list, next) {
×
UNCOV
63
        if (strcmp(tmq->name, name) == 0)
×
UNCOV
64
            return tmq;
×
UNCOV
65
    }
×
UNCOV
66
    return NULL;
×
UNCOV
67
}
×
68

69
void TmqDebugList(void)
70
{
×
71
    Tmq *tmq = NULL;
×
72
    TAILQ_FOREACH(tmq, &tmq_list, next) {
×
73
        /* get a lock accessing the len */
74
        SCMutexLock(&tmq->pq->mutex_q);
×
75
        printf("TmqDebugList: id %" PRIu32 ", name \'%s\', len %" PRIu32 "\n", tmq->id, tmq->name, tmq->pq->len);
×
76
        SCMutexUnlock(&tmq->pq->mutex_q);
×
77
    }
×
78
}
×
79

80
void TmqResetQueues(void)
UNCOV
81
{
×
UNCOV
82
    Tmq *tmq;
×
83

UNCOV
84
    while ((tmq = TAILQ_FIRST(&tmq_list))) {
×
UNCOV
85
        TAILQ_REMOVE(&tmq_list, tmq, next);
×
UNCOV
86
        if (tmq->name) {
×
UNCOV
87
            SCFree(tmq->name);
×
UNCOV
88
        }
×
UNCOV
89
        if (tmq->pq) {
×
UNCOV
90
            PacketQueueFree(tmq->pq);
×
UNCOV
91
        }
×
UNCOV
92
        SCFree(tmq);
×
UNCOV
93
    }
×
UNCOV
94
    tmq_id = 0;
×
UNCOV
95
}
×
96

97
/**
98
 * \brief Checks if all the queues allocated so far have at least one reader
99
 *        and writer.
100
 */
101
void TmValidateQueueState(void)
UNCOV
102
{
×
UNCOV
103
    bool err = false;
×
104

UNCOV
105
    Tmq *tmq = NULL;
×
UNCOV
106
    TAILQ_FOREACH(tmq, &tmq_list, next) {
×
UNCOV
107
        SCMutexLock(&tmq->pq->mutex_q);
×
UNCOV
108
        if (tmq->reader_cnt == 0) {
×
109
            SCLogError("queue \"%s\" doesn't have a reader (id %d max %u)", tmq->name, tmq->id,
×
110
                    tmq_id);
×
111
            err = true;
×
UNCOV
112
        } else if (tmq->writer_cnt == 0) {
×
113
            SCLogError("queue \"%s\" doesn't have a writer (id %d, max %u)", tmq->name, tmq->id,
×
114
                    tmq_id);
×
115
            err = true;
×
116
        }
×
UNCOV
117
        SCMutexUnlock(&tmq->pq->mutex_q);
×
118

UNCOV
119
        if (err)
×
120
            goto error;
×
UNCOV
121
    }
×
122

UNCOV
123
    return;
×
124

UNCOV
125
error:
×
126
    FatalError("fatal error during threading setup");
127
}
×
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