path: root/include/queue.h
diff options
authorPablo Neira Ayuso <>2009-01-15 23:19:58 +0100
committerPablo Neira Ayuso <>2009-01-15 23:19:58 +0100
commite2af183ea7e5ea35a1582f40a01a7c49e83b31be (patch)
tree5d5c5fabca580aa2851fb39c3e343b5bc324342e /include/queue.h
parent2cacd3a802510bde43e23cf4c7d39f51a2eaf460 (diff)
sync: unify tx_list and tx_queue into one single tx_queue
This patch unifies the tx_list and the tx_queue to have only one transmission queue. Since the tx_list hold state objects and tx_queue control messages, I have introduced a queue node type that can be used to differenciate the kind of information that the node stores: object or control message. This patch also reworks the existing queue class to include a file descriptor that can be used to know if there are new data added to the queue (see QUEUE_F_EVFD flag). In this change, I have also modified the current evfd to make the file descriptor to make read operations non-blocking. Moreover, it keeps a counter that is used to know how many messages are inserted in the queue. Signed-off-by: Pablo Neira Ayuso <>
Diffstat (limited to 'include/queue.h')
1 files changed, 38 insertions, 13 deletions
diff --git a/include/queue.h b/include/queue.h
index 5a9cf39..ef56323 100644
--- a/include/queue.h
+++ b/include/queue.h
@@ -1,28 +1,53 @@
#ifndef _QUEUE_H_
#define _QUEUE_H_
+#include <stdint.h>
#include "linux_list.h"
-struct queue {
- size_t max_size;
- size_t cur_size;
- unsigned int num_elems;
- struct list_head head;
+struct queue_node {
+ struct list_head head;
+ uint32_t type;
+ struct queue *owner;
+ size_t size;
-struct queue_node {
- struct list_head head;
- size_t size;
- char data[0];
+enum {
+ Q_ELEM_OBJ = 0,
+ Q_ELEM_CTL = 1
+void queue_node_init(struct queue_node *n, int type);
+void *queue_node_data(struct queue_node *n);
+struct queue_object {
+ struct queue_node qnode;
+ char data[0];
-struct queue *queue_create(size_t max_size);
+struct queue_object *queue_object_new(int type, size_t size);
+void queue_object_free(struct queue_object *obj);
+struct evfd;
+struct queue {
+ unsigned int max_elems;
+ unsigned int num_elems;
+ uint32_t flags;
+ struct list_head head;
+ struct evfd *evfd;
+#define QUEUE_F_EVFD (1U << 0)
+struct queue *queue_create(int max_objects, unsigned int flags);
void queue_destroy(struct queue *b);
unsigned int queue_len(const struct queue *b);
-int queue_add(struct queue *b, const void *data, size_t size);
-void queue_del(struct queue *b, void *data);
+int queue_add(struct queue *b, struct queue_node *n);
+int queue_del(struct queue_node *n);
+int queue_in(struct queue *b, struct queue_node *n);
void queue_iterate(struct queue *b,
const void *data,
- int (*iterate)(void *data1, const void *data2));
+ int (*iterate)(struct queue_node *n, const void *data2));
+int queue_get_eventfd(struct queue *b);