• 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

66.04
/src/host-queue.c
1
/* Copyright (C) 2007-2012 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
 * Host queue handler functions
24
 */
25

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

33
HostQueue *HostQueueInit (HostQueue *q)
34
{
2✔
35
    if (q != NULL) {
2✔
36
        memset(q, 0, sizeof(HostQueue));
2✔
37
        HQLOCK_INIT(q);
2✔
38
    }
2✔
39
    return q;
2✔
40
}
2✔
41

42
HostQueue *HostQueueNew(void)
43
{
×
44
    HostQueue *q = (HostQueue *)SCMalloc(sizeof(HostQueue));
×
45
    if (q == NULL) {
×
46
        SCLogError("Fatal error encountered in HostQueueNew. Exiting...");
×
47
        exit(EXIT_SUCCESS);
×
48
    }
×
49
    q = HostQueueInit(q);
×
50
    return q;
×
51
}
×
52

53
/**
54
 *  \brief Destroy a host queue
55
 *
56
 *  \param q the host queue to destroy
57
 */
58
void HostQueueDestroy (HostQueue *q)
UNCOV
59
{
×
UNCOV
60
    HQLOCK_DESTROY(q);
×
UNCOV
61
}
×
62

63
/**
64
 *  \brief add a host to a queue
65
 *
66
 *  \param q queue
67
 *  \param h host
68
 */
69
void HostEnqueue (HostQueue *q, Host *h)
70
{
2,000✔
71
#ifdef DEBUG
72
    BUG_ON(q == NULL || h == NULL);
73
#endif
74

75
    HQLOCK_LOCK(q);
2,000✔
76

77
    /* more hosts in queue */
78
    if (q->top != NULL) {
2,000✔
79
        h->lnext = q->top;
1,998✔
80
        q->top->lprev = h;
1,998✔
81
        q->top = h;
1,998✔
82
    /* only host */
83
    } else {
1,998✔
84
        q->top = h;
2✔
85
        q->bot = h;
2✔
86
    }
2✔
87
    q->len++;
2,000✔
88
#ifdef DBG_PERF
89
    if (q->len > q->dbg_maxlen)
90
        q->dbg_maxlen = q->len;
91
#endif /* DBG_PERF */
92
    HQLOCK_UNLOCK(q);
2,000✔
93
}
2,000✔
94

95
/**
96
 *  \brief remove a host from the queue
97
 *
98
 *  \param q queue
99
 *
100
 *  \retval h host or NULL if empty list.
101
 */
102
Host *HostDequeue (HostQueue *q)
103
{
49✔
104
    HQLOCK_LOCK(q);
49✔
105

106
    Host *h = q->bot;
49✔
107
    if (h == NULL) {
49✔
UNCOV
108
        HQLOCK_UNLOCK(q);
×
UNCOV
109
        return NULL;
×
UNCOV
110
    }
×
111

112
    /* more packets in queue */
113
    if (q->bot->lprev != NULL) {
49✔
114
        q->bot = q->bot->lprev;
49✔
115
        q->bot->lnext = NULL;
49✔
116
    /* just the one we remove, so now empty */
117
    } else {
49✔
UNCOV
118
        q->top = NULL;
×
UNCOV
119
        q->bot = NULL;
×
UNCOV
120
    }
×
121

122
#ifdef DEBUG
123
    BUG_ON(q->len == 0);
124
#endif
125
    if (q->len > 0)
49✔
126
        q->len--;
49✔
127

128
    h->lnext = NULL;
49✔
129
    h->lprev = NULL;
49✔
130

131
    HQLOCK_UNLOCK(q);
49✔
132
    return h;
49✔
133
}
49✔
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