From 4694ae1e0939f69f4d2696b0caff62ce6a17d92f Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Sun, 19 Jul 2009 15:31:25 +0200 Subject: conntrackd: improve handling of external messages With this patch, a) we set the file descriptors for the synchronization channels as non-blocking, b) we perform more than one recv() call per select() signal on the socket and c) we limit the iteration to the value that EventIterationLimit has set. Signed-off-by: Pablo Neira Ayuso --- src/sync-mode.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'src/sync-mode.c') diff --git a/src/sync-mode.c b/src/sync-mode.c index 7853d91..8cf7aa3 100644 --- a/src/sync-mode.c +++ b/src/sync-mode.c @@ -36,6 +36,7 @@ #include #include #include +#include static void do_channel_handler_step(int i, struct nethdr *net, size_t remain) @@ -118,7 +119,7 @@ retry: } /* handler for messages received */ -static void channel_handler(struct channel *m, int i) +static int channel_handler_routine(struct channel *m, int i) { ssize_t numbytes; ssize_t remain; @@ -126,7 +127,7 @@ static void channel_handler(struct channel *m, int i) numbytes = channel_recv(m, __net, sizeof(__net)); if (numbytes <= 0) - return; + return -1; remain = numbytes; while (remain > 0) { @@ -167,6 +168,19 @@ static void channel_handler(struct channel *m, int i) ptr += net->len; remain -= net->len; } + return 0; +} + +/* handler for messages received */ +static void channel_handler(struct channel *m, int i) +{ + int k; + + for (k=0; kchannel_num; i++) { int fd = channel_get_fd(STATE_SYNC(channel)->channel[i]); + fcntl(fd, F_SETFL, O_NONBLOCK); if (register_fd(fd, STATE(fds)) == -1) return -1; } -- cgit v1.2.3