Commit 23c08c16 authored by Nils Goroll's avatar Nils Goroll

Add VSM_NOPID environment variable to disable pid-based tests

varnishd writes its pids to vsm segments for vsm clients to
determine if varnishd processes are alive.

When running varnishd and vsm clients in different containers, the
pid information has no relevance and may even be ambiguous across
name spaces.

Setting the environment variable VSM_NOPID for vsm clients disables
use of pid information.

Patch by phk
parent 1e696ea1
......@@ -102,3 +102,22 @@ a chance to discover the deallocation.
The include file <vapi/vsm.h> provides the supported API for accessing
VSM files.
VSM and Containers
------------------
The varnish way works great with single purpose containers. By sharing
the varnish working directory read-only, vsm clients can be run in
containers separate from those running varnishd instances on the same
host.
When running varnishd and vsm clients in the same process namespace,
pid information can be used by vsm clients to determine if varnishd
processes are alive.
But, when running varnishd and vsm clients in different containers,
the pid information has no relevance and may even be ambiguous across
name spaces.
Thus, with such setups, the environment variable VSM_NOPID needs to be
set for vsm clients to disable use of pid information.
......@@ -191,6 +191,8 @@ VSM_New(void)
vd->child = vsm_newset(VSM_CHILD_DIRNAME);
vd->dfd = -1;
vd->patience = 5;
if (getenv("VSM_NOPID") != NULL)
vd->couldkill = -1;
return (vd);
}
......@@ -350,7 +352,7 @@ vsm_refresh_set2(struct vsm *vd, struct vsm_set *vs, struct vsb *vsb)
}
if (vs->fd >= 0) {
if (!vd->couldkill || !kill(vs->id1, 0))
if (vd->couldkill < 1 || !kill(vs->id1, 0))
retval |= VSM_MGT_RUNNING;
return (retval);
}
......@@ -385,9 +387,9 @@ vsm_refresh_set2(struct vsm *vd, struct vsm_set *vs, struct vsb *vsb)
retval |= VSM_MGT_RESTARTED | VSM_MGT_CHANGED;
return (retval);
}
if (!kill(id1, 0)) {
if (vd->couldkill >= 0 && !kill(id1, 0)) {
vd->couldkill = 1;
} else if (vd->couldkill && errno == ESRCH) {
} else if (vd->couldkill > 0 && errno == ESRCH) {
retval |= VSM_MGT_RESTARTED | VSM_MGT_CHANGED;
return (retval);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment