summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2009-07-17 13:33:36 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2009-07-17 13:33:36 +0200
commit9406f29b89f6727c3db5485d109466701393b4d4 (patch)
tree6b5b9898b6bd9063d26087450b9044f2e500a80f /src
parent589fd85fa48b8e1da2debd08b90a6062cf64ef15 (diff)
downloadconntrack-tools-9406f29b89f6727c3db5485d109466701393b4d4.tar.gz
conntrack-tools-9406f29b89f6727c3db5485d109466701393b4d4.zip
local: add LOCAL_RET_* return values for UNIX sockets callbacks
This patch adds the LOCAL_RET_* return values. The return value LOCAL_RET_STOLEN which allows to leave a client socket open while waiting for an operation to finish. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src')
-rw-r--r--src/local.c7
-rw-r--r--src/run.c22
-rw-r--r--src/stats-mode.c2
-rw-r--r--src/sync-ftfw.c5
-rw-r--r--src/sync-mode.c2
5 files changed, 20 insertions, 18 deletions
diff --git a/src/local.c b/src/local.c
index 4739e56..feff608 100644
--- a/src/local.c
+++ b/src/local.c
@@ -72,7 +72,7 @@ void local_server_destroy(struct local_server *server)
}
int do_local_server_step(struct local_server *server, void *data,
- void (*process)(int fd, void *data))
+ int (*process)(int fd, void *data))
{
int rfd;
struct sockaddr_un local;
@@ -82,8 +82,9 @@ int do_local_server_step(struct local_server *server, void *data,
if (rfd == -1)
return -1;
- process(rfd, data);
- close(rfd);
+ /* This descriptor will be closed later, we ignore OK and errors */
+ if (process(rfd, data) != LOCAL_RET_STOLEN)
+ close(rfd);
return 0;
}
diff --git a/src/run.c b/src/run.c
index 95d51a2..87b6fb2 100644
--- a/src/run.c
+++ b/src/run.c
@@ -182,18 +182,18 @@ static void dump_stats_runtime(int fd)
send(fd, buf, size, 0);
}
-void local_handler(int fd, void *data)
+static int local_handler(int fd, void *data)
{
- int ret;
+ int ret = LOCAL_RET_OK;
int type;
ret = read(fd, &type, sizeof(type));
if (ret == -1) {
STATE(stats).local_read_failed++;
- return;
+ return LOCAL_RET_OK;
}
if (ret == 0)
- return;
+ return LOCAL_RET_OK;
switch(type) {
case FLUSH_MASTER:
@@ -207,22 +207,26 @@ void local_handler(int fd, void *data)
nl_flush_conntrack_table(STATE(flush));
exit(EXIT_SUCCESS);
}
- return;
+ break;
case RESYNC_MASTER:
STATE(stats).nl_kernel_table_resync++;
dlog(LOG_NOTICE, "resync with master table");
nl_dump_conntrack_table(STATE(dump));
- return;
+ break;
case STATS_RUNTIME:
dump_stats_runtime(fd);
- return;
+ break;
case STATS_PROCESS:
fork_process_dump(fd);
- return;
+ break;
}
- if (!STATE(mode)->local(fd, type, data))
+ ret = STATE(mode)->local(fd, type, data);
+ if (ret == LOCAL_RET_ERROR) {
STATE(stats).local_unknown_request++;
+ return LOCAL_RET_ERROR;
+ }
+ return ret;
}
static void do_overrun_resync_alarm(struct alarm_block *a, void *data)
diff --git a/src/stats-mode.c b/src/stats-mode.c
index b84c7a1..5cfb638 100644
--- a/src/stats-mode.c
+++ b/src/stats-mode.c
@@ -55,7 +55,7 @@ static void kill_stats(void)
/* handler for requests coming via UNIX socket */
static int local_handler_stats(int fd, int type, void *data)
{
- int ret = 1;
+ int ret = LOCAL_RET_OK;
switch(type) {
case DUMP_INTERNAL:
diff --git a/src/sync-ftfw.c b/src/sync-ftfw.c
index bf9f4f7..0d31e17 100644
--- a/src/sync-ftfw.c
+++ b/src/sync-ftfw.c
@@ -215,7 +215,7 @@ static void ftfw_local_queue(int fd)
static int ftfw_local(int fd, int type, void *data)
{
- int ret = 1;
+ int ret = LOCAL_RET_OK;
switch(type) {
case REQUEST_DUMP:
@@ -229,9 +229,6 @@ static int ftfw_local(int fd, int type, void *data)
case STATS_RSQUEUE:
ftfw_local_queue(fd);
break;
- default:
- ret = 0;
- break;
}
return ret;
diff --git a/src/sync-mode.c b/src/sync-mode.c
index 4d6956e..b0e2b02 100644
--- a/src/sync-mode.c
+++ b/src/sync-mode.c
@@ -403,7 +403,7 @@ static void dump_stats_sync_extended(int fd)
/* handler for requests coming via UNIX socket */
static int local_handler_sync(int fd, int type, void *data)
{
- int ret = 1;
+ int ret = LOCAL_RET_OK;
switch(type) {
case DUMP_INTERNAL: