aboutsummaryrefslogtreecommitdiff
path: root/gacopyz
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2007-05-04 05:37:38 +0000
committerSergey Poznyakoff <gray@gnu.org.ua>2007-05-04 05:37:38 +0000
commit5663888746b3b5e15ab795a1e2bfaae7b2cf768a (patch)
treee1ee007db83ea3832d450ae4d6e2df7010cfbed9 /gacopyz
parent076f7df5c40dbc3c791f14e5f55568e46244c0f8 (diff)
downloadmailfromd-5663888746b3b5e15ab795a1e2bfaae7b2cf768a.tar.gz
mailfromd-5663888746b3b5e15ab795a1e2bfaae7b2cf768a.tar.bz2
SIGHUP instructs `mailfromd' to restart itself.
Remove UNIX socket after closing it. git-svn-id: file:///svnroot/mailfromd/trunk@1405 7a8a7f39-df28-0410-adc6-e0d955640f24
Diffstat (limited to 'gacopyz')
-rw-r--r--gacopyz/gacopyz.c16
-rw-r--r--gacopyz/gacopyz_priv.h2
-rw-r--r--gacopyz/proc.c3
3 files changed, 20 insertions, 1 deletions
diff --git a/gacopyz/gacopyz.c b/gacopyz/gacopyz.c
index a7a50177..c3aeb453 100644
--- a/gacopyz/gacopyz.c
+++ b/gacopyz/gacopyz.c
@@ -135,6 +135,17 @@ parse_connection(gacopyz_conn_t conn,
}
+static void
+cleanup_unix_socket(gacopyz_conn_t conn, void *data)
+{
+ if (unlink(data))
+ gacopyz_log(conn, SMI_LOG_ERR,
+ "%s: %s: cannot unlink: %s",
+ conn->desc.xxfi_name, (char*)data,
+ strerror(errno));
+ free(data);
+}
+
static int
do_connect(gacopyz_conn_t conn,
const char *cstr, char *proto, char *port, char *path,
@@ -174,7 +185,10 @@ do_connect(gacopyz_conn_t conn,
strcpy(addr.sun.sun_path, path);
if (stat(path, &st)) {
- if (errno != ENOENT) {
+ if (errno == ENOENT) {
+ conn->cleanup = cleanup_unix_socket;
+ conn->cleanup_data = strdup(path);
+ } else {
gacopyz_log(conn, SMI_LOG_ERR,
"%s: %s: cannot stat socket: %s",
conn->desc.xxfi_name, path,
diff --git a/gacopyz/gacopyz_priv.h b/gacopyz/gacopyz_priv.h
index 30486f42..7f5bdd69 100644
--- a/gacopyz/gacopyz_priv.h
+++ b/gacopyz/gacopyz_priv.h
@@ -61,6 +61,8 @@ struct gacopyz_conn {
struct smfiDesc desc;
pid_t *pidtab;
size_t pidcount;
+ void (*cleanup) (gacopyz_conn_t, void*);
+ void *cleanup_data;
};
#define GACOPYZ_TIMEOUT 7210
diff --git a/gacopyz/proc.c b/gacopyz/proc.c
index d388c1fa..7bce35f1 100644
--- a/gacopyz/proc.c
+++ b/gacopyz/proc.c
@@ -126,6 +126,9 @@ gacopyz_cleanup_conn(gacopyz_conn_t conn)
if (conn->pidtab[i])
kill(conn->pidtab[i], SIGTERM);
cleanup_children(conn, 1);
+
+ if (conn->cleanup)
+ conn->cleanup(conn, conn->cleanup_data);
}
static RETSIGTYPE

Return to:

Send suggestions and report system problems to the System administrator.