uint32_t default_packet_size;
#define SIZE_OF_PACKET (default_packet_size + sizeof(Packet))
+/** \brief simple fifo queue for packets
+ *
+ * \note PacketQueueNoLock and PacketQueue need to keep identical
+ * layouts except for the mutex_q and cond_q fields.
+ */
+typedef struct PacketQueueNoLock_ {
+ Packet *top;
+ Packet *bot;
+ uint32_t len;
+#ifdef DBG_PERF
+ uint32_t dbg_maxlen;
+#endif /* DBG_PERF */
+} PacketQueueNoLock;
+
+/** \brief simple fifo queue for packets with mutex and cond
+ * Calling the mutex or triggering the cond is responsibility of the caller
+ *
+ * \note PacketQueueNoLock and PacketQueue need to keep identical
+ * layouts except for the mutex_q and cond_q fields.
+ */
typedef struct PacketQueue_ {
Packet *top;
Packet *bot;
-/* Copyright (C) 2007-2010 Open Information Security Foundation
+/* Copyright (C) 2007-2019 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
}
#endif /* DEBUG */
-void PacketEnqueue (PacketQueue *q, Packet *p)
+static inline void PacketEnqueueDo(PacketQueue *q, Packet *p)
{
//PacketQueueValidateDebug(q);
//PacketQueueValidateDebug(q);
}
-Packet *PacketDequeue (PacketQueue *q)
+void PacketEnqueueNoLock(PacketQueueNoLock *qnl, Packet *p)
+{
+ PacketQueue *q = (PacketQueue *)qnl;
+ PacketEnqueueDo(q, p);
+}
+
+void PacketEnqueue (PacketQueue *q, Packet *p)
{
- Packet *p = NULL;
+ PacketEnqueueDo(q, p);
+}
+static inline Packet *PacketDequeueDo (PacketQueue *q)
+{
//PacketQueueValidateDebug(q);
/* if the queue is empty there are no packets left. */
if (q->len == 0) {
return NULL;
}
-
q->len--;
/* pull the bottom packet from the queue */
- p = q->bot;
-
- /* Weird issue: sometimes it looks that two thread arrive
- * here at the same time so the bot ptr is NULL (only on OS X?)
- */
- BUG_ON (p == NULL);
+ Packet *p = q->bot;
/* more packets in queue */
if (q->bot->prev != NULL) {
return p;
}
+Packet *PacketDequeueNoLock (PacketQueueNoLock *qnl)
+{
+ PacketQueue *q = (PacketQueue *)qnl;
+ return PacketDequeueDo(q);
+}
+
+Packet *PacketDequeue (PacketQueue *q)
+{
+ return PacketDequeueDo(q);
+}
-/* Copyright (C) 2007-2010 Open Information Security Foundation
+/* Copyright (C) 2007-2019 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
#include "threads.h"
#include "decode.h"
+void PacketEnqueueNoLock(PacketQueueNoLock *qnl, Packet *p);
void PacketEnqueue (PacketQueue *, Packet *);
+
+Packet *PacketDequeueNoLock (PacketQueueNoLock *qnl);
Packet *PacketDequeue (PacketQueue *);
#endif /* __PACKET_QUEUE_H__ */