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