diff options
author | Pablo Neira Ayuso <pablo@netfilter.org> | 2009-01-15 23:19:58 +0100 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2009-01-15 23:19:58 +0100 |
commit | e2af183ea7e5ea35a1582f40a01a7c49e83b31be (patch) | |
tree | 5d5c5fabca580aa2851fb39c3e343b5bc324342e /src/sync-mode.c | |
parent | 2cacd3a802510bde43e23cf4c7d39f51a2eaf460 (diff) | |
download | conntrack-tools-e2af183ea7e5ea35a1582f40a01a7c49e83b31be.tar.gz conntrack-tools-e2af183ea7e5ea35a1582f40a01a7c49e83b31be.zip |
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 <pablo@netfilter.org>
Diffstat (limited to 'src/sync-mode.c')
-rw-r--r-- | src/sync-mode.c | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/src/sync-mode.c b/src/sync-mode.c index 368984f..711f71b 100644 --- a/src/sync-mode.c +++ b/src/sync-mode.c @@ -242,12 +242,6 @@ static int init_sync(void) return -1; } - STATE_SYNC(evfd) = create_evfd(); - if (STATE_SYNC(evfd) == NULL) { - dlog(LOG_ERR, "cannot open evfd"); - return -1; - } - /* initialization of multicast sequence generation */ STATE_SYNC(last_seq_sent) = time(NULL); @@ -259,7 +253,10 @@ static int register_fds_sync(struct fds *fds) if (register_fd(STATE_SYNC(mcast_server->fd), fds) == -1) return -1; - return register_fd(get_read_evfd(STATE_SYNC(evfd)), fds); + if (STATE_SYNC(sync)->register_fds) + return STATE_SYNC(sync)->register_fds(fds); + + return 0; } static void run_sync(fd_set *readfds) @@ -268,11 +265,8 @@ static void run_sync(fd_set *readfds) if (FD_ISSET(STATE_SYNC(mcast_server->fd), readfds)) mcast_handler(); - if (FD_ISSET(get_read_evfd(STATE_SYNC(evfd)), readfds) && - STATE_SYNC(sync)->run) { - read_evfd(STATE_SYNC(evfd)); - STATE_SYNC(sync)->run(); - } + if (STATE_SYNC(sync)->run) + STATE_SYNC(sync)->run(readfds); /* flush pending messages */ mcast_buffered_pending_netmsg(STATE_SYNC(mcast_client)); @@ -286,8 +280,6 @@ static void kill_sync(void) mcast_server_destroy(STATE_SYNC(mcast_server)); mcast_client_destroy(STATE_SYNC(mcast_client)); - destroy_evfd(STATE_SYNC(evfd)); - mcast_buffered_destroy(); if (STATE_SYNC(sync)->kill) |