[master] 15a6fdf More comprehensive cleanup in the -n directory on exit.
Poul-Henning Kamp
phk at FreeBSD.org
Tue Apr 14 10:23:12 CEST 2015
commit 15a6fdf739ce87b6fa61613c57a1e3b34698941e
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Tue Apr 14 08:22:51 2015 +0000
More comprehensive cleanup in the -n directory on exit.
diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c
index 5ea594c..7e98190 100644
--- a/bin/varnishd/mgt/mgt_main.c
+++ b/bin/varnishd/mgt/mgt_main.c
@@ -301,6 +301,18 @@ cli_stdin_close(void *priv)
/*--------------------------------------------------------------------*/
+static void
+mgt_secret_atexit(void)
+{
+
+ /* Only master process */
+ if (getpid() != mgt_pid)
+ return;
+ VJ_master(JAIL_MASTER_FILE);
+ AZ(unlink("_.secret"));
+ VJ_master(JAIL_MASTER_LOW);
+}
+
static const char *
make_secret(const char *dirname)
{
@@ -311,6 +323,7 @@ make_secret(const char *dirname)
assert(asprintf(&fn, "%s/_.secret", dirname) > 0);
+ VJ_master(JAIL_MASTER_FILE);
fd = open(fn, O_RDWR|O_CREAT|O_TRUNC, 0600);
if (fd < 0) {
fprintf(stderr, "Cannot create secret-file in %s (%s)\n",
@@ -322,6 +335,8 @@ make_secret(const char *dirname)
buf[i] = random() & 0xff;
assert(sizeof buf == write(fd, buf, sizeof buf));
AZ(close(fd));
+ VJ_master(JAIL_MASTER_LOW);
+ AZ(atexit(mgt_secret_atexit));
return (fn);
}
diff --git a/bin/varnishd/mgt/mgt_shmem.c b/bin/varnishd/mgt/mgt_shmem.c
index 66c87de..f0a9141 100644
--- a/bin/varnishd/mgt/mgt_shmem.c
+++ b/bin/varnishd/mgt/mgt_shmem.c
@@ -305,8 +305,7 @@ mgt_SHM_Size_Adjust(void)
* Exit handler that clears the owning pid from the SHMLOG
*/
-static
-void
+static void
mgt_shm_atexit(void)
{
diff --git a/bin/varnishd/mgt/mgt_vcl.c b/bin/varnishd/mgt/mgt_vcl.c
index 062c9ca..743b57f 100644
--- a/bin/varnishd/mgt/mgt_vcl.c
+++ b/bin/varnishd/mgt/mgt_vcl.c
@@ -90,9 +90,14 @@ mgt_vcl_add(const char *name, const char *libfile, const char *state)
static void
mgt_vcl_del(struct vclprog *vp)
{
+ char dn[256];
+
VTAILQ_REMOVE(&vclhead, vp, list);
- printf("unlink %s\n", vp->fname);
XXXAZ(unlink(vp->fname));
+ bprintf(dn, "vcl_%s", vp->name);
+ VJ_master(JAIL_MASTER_FILE);
+ XXXAZ(rmdir(dn));
+ VJ_master(JAIL_MASTER_LOW);
free(vp->fname);
free(vp->name);
free(vp);
@@ -448,13 +453,11 @@ mgt_vcl_atexit(void)
if (getpid() != mgt_pid)
return;
- while (1) {
+ do {
vp = VTAILQ_FIRST(&vclhead);
- if (vp == NULL)
- break;
- (void)unlink(vp->fname);
- VTAILQ_REMOVE(&vclhead, vp, list);
- }
+ if (vp != NULL)
+ mgt_vcl_del(vp);
+ } while (vp != NULL);
}
void
More information about the varnish-commit
mailing list