From 5b4129a89e9fa3ea3b5d57fc362f682aa85abfc7 Mon Sep 17 00:00:00 2001 From: "/C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org" Date: Tue, 15 Jan 2008 15:41:13 +0000 Subject: remove unix socket file on exit --- ChangeLog | 1 + include/local.h | 2 +- src/local.c | 6 +++++- src/run.c | 2 +- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6256ee6..75ead6b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -43,6 +43,7 @@ o add support for tagged vlan interfaces in the config file, e.g. eth0.1 o improve alarm framework based on suggestions from Max Kellerman o constify queue_iterate() o use list_del_init() and list_empty() to check if a node is in the list +o remove unix socket file on exit Max Kellermann : diff --git a/include/local.h b/include/local.h index 350b8bf..aae73a7 100644 --- a/include/local.h +++ b/include/local.h @@ -15,7 +15,7 @@ struct local_conf { /* local server */ int local_server_create(struct local_conf *conf); -void local_server_destroy(int fd); +void local_server_destroy(int fd, const char *); int do_local_server_step(int fd, void *data, void (*process)(int fd, void *data)); diff --git a/src/local.c b/src/local.c index 9ff5f82..d861e12 100644 --- a/src/local.c +++ b/src/local.c @@ -37,6 +37,7 @@ int local_server_create(struct local_conf *conf) if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &conf->reuseaddr, sizeof(conf->reuseaddr)) == -1) { close(fd); + unlink(conf->path); return -1; } @@ -47,19 +48,22 @@ int local_server_create(struct local_conf *conf) if (bind(fd, (struct sockaddr *) &local, len) == -1) { close(fd); + unlink(conf->path); return -1; } if (listen(fd, conf->backlog) == -1) { close(fd); + unlink(conf->path); return -1; } return fd; } -void local_server_destroy(int fd) +void local_server_destroy(int fd, const char *path) { + unlink(path); close(fd); } diff --git a/src/run.c b/src/run.c index 3fd98cd..cb5116d 100644 --- a/src/run.c +++ b/src/run.c @@ -43,7 +43,7 @@ void killer(int foo) nfct_close(STATE(dump)); ignore_pool_destroy(STATE(ignore_pool)); - local_server_destroy(STATE(local)); + local_server_destroy(STATE(local), CONFIG(local).path); STATE(mode)->kill(); unlink(CONFIG(lockfile)); dlog(STATE(log), LOG_NOTICE, "---- shutdown received ----"); -- cgit v1.2.3