diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/conntrackd.h | 1 | ||||
-rw-r--r-- | include/queue.h | 51 | ||||
-rw-r--r-- | include/sync.h | 6 |
3 files changed, 43 insertions, 15 deletions
diff --git a/include/conntrackd.h b/include/conntrackd.h index 67397b8..8cb520d 100644 --- a/include/conntrackd.h +++ b/include/conntrackd.h @@ -150,7 +150,6 @@ struct ct_sync_state { struct mcast_sock *mcast_server; /* multicast socket: incoming */ struct mcast_sock *mcast_client; /* multicast socket: outgoing */ - struct evfd *evfd; /* event fd */ struct sync_mode *sync; /* sync mode */ 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); #endif diff --git a/include/sync.h b/include/sync.h index 60c9fae..9a9540c 100644 --- a/include/sync.h +++ b/include/sync.h @@ -1,8 +1,11 @@ #ifndef _SYNC_HOOKS_H_ #define _SYNC_HOOKS_H_ +#include <sys/select.h> + struct nethdr; struct cache_object; +struct fds; struct sync_mode { int internal_cache_flags; @@ -15,7 +18,8 @@ struct sync_mode { int (*local)(int fd, int type, void *data); int (*recv)(const struct nethdr *net); void (*send)(struct nethdr *net, struct cache_object *obj); - void (*run)(void); + void (*run)(fd_set *readfds); + int (*register_fds)(struct fds *fds); }; extern struct sync_mode sync_alarm; |