diff options
author | Pablo Neira Ayuso <pablo@netfilter.org> | 2008-05-25 15:14:31 +0200 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2008-05-25 15:14:31 +0200 |
commit | ed49d60424a18635c31dafc77e2cb720f75cc4ff (patch) | |
tree | a03fa967fc353777eb20d5b81dfd46430e38c45e /src/sync-mode.c | |
parent | ed50c346126f5385163d03bc9639d28ead6c8536 (diff) | |
download | conntrack-tools-ed49d60424a18635c31dafc77e2cb720f75cc4ff.tar.gz conntrack-tools-ed49d60424a18635c31dafc77e2cb720f75cc4ff.zip |
add eventfd emulation to communicate receiver -> sender
Diffstat (limited to 'src/sync-mode.c')
-rw-r--r-- | src/sync-mode.c | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/src/sync-mode.c b/src/sync-mode.c index ad55adc..2fe7406 100644 --- a/src/sync-mode.c +++ b/src/sync-mode.c @@ -26,6 +26,7 @@ #include "us-conntrack.h" #include "network.h" #include "fds.h" +#include "event.h" #include "debug.h" #include <errno.h> @@ -232,6 +233,12 @@ 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); @@ -240,21 +247,26 @@ static int init_sync(void) static int register_fds_sync(struct fds *fds) { - return register_fd(STATE_SYNC(mcast_server->fd), fds); + if (register_fd(STATE_SYNC(mcast_server->fd), fds) == -1) + return -1; + + return register_fd(get_read_evfd(STATE_SYNC(evfd)), fds); } static void run_sync(fd_set *readfds) { /* multicast packet has been received */ - if (FD_ISSET(STATE_SYNC(mcast_server->fd), readfds)) { + if (FD_ISSET(STATE_SYNC(mcast_server->fd), readfds)) mcast_handler(); - if (STATE_SYNC(sync)->run) - STATE_SYNC(sync)->run(); - - /* flush pending messages */ - mcast_buffered_pending_netmsg(STATE_SYNC(mcast_client)); + if (FD_ISSET(get_read_evfd(STATE_SYNC(evfd)), readfds) && + STATE_SYNC(sync)->run) { + read_evfd(STATE_SYNC(evfd)); + STATE_SYNC(sync)->run(); } + + /* flush pending messages */ + mcast_buffered_pending_netmsg(STATE_SYNC(mcast_client)); } static void kill_sync(void) @@ -265,6 +277,8 @@ 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) |