Commit e82877ea authored by Ingvar Hagelund's avatar Ingvar Hagelund
parents 3dbab85b ad9356a9
......@@ -194,6 +194,7 @@ pool_accept(struct worker *wrk, void *arg)
return;
}
VTAILQ_REMOVE(&pp->idle_queue, &wrk2->task, list);
AZ(wrk2->task.func);
Lck_Unlock(&pp->mtx);
assert(sizeof *wa2 == WS_Reserve(wrk2->aws, sizeof *wa2));
wa2 = (void*)wrk2->aws->f;
......@@ -227,6 +228,7 @@ Pool_Task(struct pool *pp, struct pool_task *task, enum pool_how how)
wrk = pool_getidleworker(pp, 0);
if (wrk != NULL) {
VTAILQ_REMOVE(&pp->idle_queue, &wrk->task, list);
AZ(wrk->task.func);
Lck_Unlock(&pp->mtx);
wrk->task.func = task->func;
wrk->task.priv = task->priv;
......@@ -298,6 +300,7 @@ Pool_Work_Thread(void *priv, struct worker *wrk)
wrk->lastused = VTIM_real();
wrk->task.func = NULL;
wrk->task.priv = wrk;
AZ(wrk->task.func);
VTAILQ_INSERT_HEAD(&pp->idle_queue, &wrk->task, list);
if (!stats_clean)
WRK_SumStat(wrk);
......@@ -427,6 +430,7 @@ pool_herder(void *priv)
if (wrk != NULL && (wrk->lastused < t_idle ||
pp->nthr > cache_param->wthread_max)) {
VTAILQ_REMOVE(&pp->idle_queue, &wrk->task, list);
AZ(wrk->task.func);
} else
wrk = NULL;
Lck_Unlock(&pp->mtx);
......
......@@ -394,18 +394,16 @@ mgt_vcc_default(const char *b_arg, const char *f_arg, char *vcl, int C_flag)
if (VSB_len(sb) > 0)
fprintf(stderr, "%s", VSB_data(sb));
VSB_delete(sb);
if (C_flag) {
if (vf != NULL)
AZ(unlink(vf));
return (0);
}
if (C_flag && vf != NULL)
AZ(unlink(vf));
if (vf == NULL) {
fprintf(stderr, "\nVCL compilation failed\n");
return (1);
} else {
vp = mgt_vcc_add(buf, vf);
vp->active = 1;
return (0);
}
vp = mgt_vcc_add(buf, vf);
vp->active = 1;
return (0);
}
/*--------------------------------------------------------------------*/
......
......@@ -87,6 +87,8 @@ macro_def(struct vtclog *vl, const char *instance, const char *name,
struct macro *m;
va_list ap;
AN(fmt);
if (instance != NULL) {
bprintf(buf1, "%s_%s", instance, name);
name = buf1;
......@@ -96,23 +98,40 @@ macro_def(struct vtclog *vl, const char *instance, const char *name,
VTAILQ_FOREACH(m, &macro_list, list)
if (!strcmp(name, m->name))
break;
if (m == NULL && fmt != NULL) {
if (m == NULL) {
m = calloc(sizeof *m, 1);
AN(m);
REPLACE(m->name, name);
VTAILQ_INSERT_TAIL(&macro_list, m, list);
}
if (fmt != NULL) {
AN(m);
va_start(ap, fmt);
free(m->val);
m->val = NULL;
vbprintf(buf2, fmt, ap);
va_end(ap);
m->val = strdup(buf2);
AN(m->val);
vtc_log(vl, 4, "macro def %s=%s", name, m->val);
} else if (m != NULL) {
AN(m);
va_start(ap, fmt);
free(m->val);
m->val = NULL;
vbprintf(buf2, fmt, ap);
va_end(ap);
m->val = strdup(buf2);
AN(m->val);
vtc_log(vl, 4, "macro def %s=%s", name, m->val);
AZ(pthread_mutex_unlock(&macro_mtx));
}
void
macro_undef(struct vtclog *vl, const char *instance, const char *name)
{
char buf1[256];
struct macro *m;
if (instance != NULL) {
bprintf(buf1, "%s_%s", instance, name);
name = buf1;
}
AZ(pthread_mutex_lock(&macro_mtx));
VTAILQ_FOREACH(m, &macro_list, list)
if (!strcmp(name, m->name))
break;
if (m != NULL) {
vtc_log(vl, 4, "macro undef %s", name);
VTAILQ_REMOVE(&macro_list, m, list);
free(m->name);
......
......@@ -87,6 +87,7 @@ void vtc_hexdump(struct vtclog *vl, int lvl, const char *pfx,
int exec_file(const char *fn, const char *script, const char *tmpdir,
char *logbuf, unsigned loglen);
void macro_undef(struct vtclog *vl, const char *instance, const char *name);
void macro_def(struct vtclog *vl, const char *instance, const char *name,
const char *fmt, ...)
__printflike(4, 5);
......
......@@ -143,9 +143,9 @@ server_delete(struct server *s)
{
CHECK_OBJ_NOTNULL(s, SERVER_MAGIC);
macro_def(s->vl, s->name, "addr", NULL);
macro_def(s->vl, s->name, "port", NULL);
macro_def(s->vl, s->name, "sock", NULL);
macro_undef(s->vl, s->name, "addr");
macro_undef(s->vl, s->name, "port");
macro_undef(s->vl, s->name, "sock");
vtc_logclose(s->vl);
free(s->name);
/* XXX: MEMLEAK (?) (VSS ??) */
......
......@@ -522,9 +522,9 @@ varnish_stop(struct varnish *v)
varnish_launch(v);
if (vtc_error)
return;
macro_def(v->vl, v->name, "addr", NULL);
macro_def(v->vl, v->name, "port", NULL);
macro_def(v->vl, v->name, "sock", NULL);
macro_undef(v->vl, v->name, "addr");
macro_undef(v->vl, v->name, "port");
macro_undef(v->vl, v->name, "sock");
vtc_log(v->vl, 2, "Stop");
(void)varnish_ask_cli(v, "stop", NULL);
while (1) {
......
......@@ -22,7 +22,9 @@ have three ESI statements:
Content substitution based on variables and cookies is not implemented
but is on the roadmap.
Example: esi include
Varnish will not process ESI instructions in HTML comments.
Example: esi:include
~~~~~~~~~~~~~~~~~~~~
Lets see an example how this could be used. This simple cgi script
......@@ -55,32 +57,23 @@ For ESI to work you need to activate ESI processing in VCL, like this::
}
}
Example: esi remove
~~~~~~~~~~~~~~~~~~~
The *remove* keyword allows you to remove output. You can use this to make
a fall back of sorts, when ESI is not available, like this::
Example: esi:remove and <!--esi ... -->
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The <esi:remove> and <!--esi ... --> constructs can be used to present
appropriate content whether or not ESI is available, for example you can
include content when ESI is available or link to it when it is not.
ESI processors will remove the start ("<!--esi") and end ("-->") when
the page is processed, while still processing the contents. If the page
is not processed, it will remain, becoming an HTML/XML comment tag.
ESI processors will remove <esi:remove> tags and all content contained
in them, allowing you to only render the content when the page is not
being ESI-processed.
For example::
<esi:include src="http://www.example.com/ad.html"/>
<esi:remove>
<a href="http://www.example.com">www.example.com</a>
<a href="http://www.example.com/LICENSE">The license</a>
</esi:remove>
Example: <!--esi ... -->
~~~~~~~~~~~~~~~~~~~~~~~~
This is a special construct to allow HTML marked up with ESI to render
without processing. ESI Processors will remove the start ("<!--esi")
and end ("-->") when the page is processed, while still processing the
contents. If the page is not processed, it will remain, becoming an
HTML/XML comment tag. For example::
<!--esi
<p>Warning: ESI Disabled!</p>
</p> -->
This assures that the ESI markup will not interfere with the rendering
of the final HTML if not processed.
<p>The full text of the license:</p>
<esi:include src="http://example.com/LICENSE" />
-->
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