[master] e85eec4 With the new sbuf version, vsb_finish() reports any errors, so we can save a lot of asserts and calls.
Poul-Henning Kamp
phk at varnish-cache.org
Mon Apr 4 16:05:26 CEST 2011
commit e85eec42dfa4b5913fa4d4876b748896ce2a8bd2
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Mon Apr 4 14:04:45 2011 +0000
With the new sbuf version, vsb_finish() reports any errors, so we
can save a lot of asserts and calls.
diff --git a/bin/varnishd/cache_backend_poll.c b/bin/varnishd/cache_backend_poll.c
index 9cf241c..abd5ccc 100644
--- a/bin/varnishd/cache_backend_poll.c
+++ b/bin/varnishd/cache_backend_poll.c
@@ -322,8 +322,7 @@ vbp_build_req(struct vsb *vsb, const struct vbp_vcl *vcl)
vsb_printf(vsb, "Connection: close\r\n");
vsb_printf(vsb, "\r\n");
}
- vsb_finish(vsb);
- AZ(vsb_error(vsb));
+ AZ(vsb_finish(vsb));
}
/*--------------------------------------------------------------------
diff --git a/bin/varnishd/cache_ban.c b/bin/varnishd/cache_ban.c
index c21db4f..0d27bbc 100644
--- a/bin/varnishd/cache_ban.c
+++ b/bin/varnishd/cache_ban.c
@@ -313,8 +313,7 @@ BAN_Insert(struct ban *b)
CHECK_OBJ_NOTNULL(b, BAN_MAGIC);
b->t0 = TIM_real();
- vsb_finish(b->vsb);
- AZ(vsb_error(b->vsb));
+ AZ(vsb_finish(b->vsb));
b->test = strdup(vsb_data(b->vsb));
AN(b->test);
vsb_delete(b->vsb);
diff --git a/bin/varnishd/cache_esi_parse.c b/bin/varnishd/cache_esi_parse.c
index ad18a86..d8d4f88 100644
--- a/bin/varnishd/cache_esi_parse.c
+++ b/bin/varnishd/cache_esi_parse.c
@@ -875,7 +875,7 @@ VEP_parse(const struct sess *sp, const char *p, size_t l)
vep->state = VEP_TAGERROR;
vep->attr_delim = 0;
if (vep->attr_vsb != NULL) {
- vsb_finish(vep->attr_vsb);
+ AZ(vsb_finish(vep->attr_vsb));
vsb_delete(vep->attr_vsb);
vep->attr_vsb = NULL;
}
@@ -884,7 +884,7 @@ VEP_parse(const struct sess *sp, const char *p, size_t l)
p++;
vep->state = VEP_INTAG;
if (vep->attr_vsb != NULL) {
- vsb_finish(vep->attr_vsb);
+ AZ(vsb_finish(vep->attr_vsb));
AN(vep->dostuff);
vep->dostuff(vep, DO_ATTR);
vep->attr_vsb = NULL;
@@ -1056,7 +1056,7 @@ VEP_Finish(const struct sess *sp)
sp->wrk->vep = NULL;
- vsb_finish(vep->vsb);
+ AZ(vsb_finish(vep->vsb));
l = vsb_len(vep->vsb);
if (vep->state != VEP_NOTXML && l > 0)
return (vep->vsb);
diff --git a/bin/varnishd/cache_vary.c b/bin/varnishd/cache_vary.c
index f079156..69ff52f 100644
--- a/bin/varnishd/cache_vary.c
+++ b/bin/varnishd/cache_vary.c
@@ -97,8 +97,7 @@ VRY_Create(const struct sess *sp, const struct http *hp)
/* Build a header-matching string out of it */
vsb_clear(sbh);
vsb_printf(sbh, "%c%.*s:%c", 1 + (q - p), q - p, p, 0);
- vsb_finish(sbh);
- AZ(vsb_error(sbh));
+ AZ(vsb_finish(sbh));
/* Append to vary matching string */
vsb_bcat(sb, vsb_data(sbh), vsb_len(sbh));
@@ -131,8 +130,7 @@ VRY_Create(const struct sess *sp, const struct http *hp)
vsb_printf(sb, "%c", 0);
vsb_delete(sbh);
- vsb_finish(sb);
- AZ(vsb_error(sb));
+ AZ(vsb_finish(sb));
return(sb);
}
diff --git a/bin/varnishd/mgt_child.c b/bin/varnishd/mgt_child.c
index a11da9e..df8c77f 100644
--- a/bin/varnishd/mgt_child.c
+++ b/bin/varnishd/mgt_child.c
@@ -449,8 +449,7 @@ mgt_save_panic(void)
TIM_format(TIM_real(), time_str);
vsb_printf(child_panic, "Last panic at: %s\n", time_str);
vsb_cat(child_panic, vsm_head->panicstr);
- vsb_finish(child_panic);
- AZ(vsb_error(child_panic));
+ AZ(vsb_finish(child_panic));
}
static void
@@ -499,8 +498,7 @@ mgt_sigchld(const struct vev *e, int what)
exit_status |= 0x80;
}
#endif
- vsb_finish(vsb);
- AZ(vsb_error(vsb));
+ AZ(vsb_finish(vsb));
REPORT(LOG_INFO, "%s", vsb_data(vsb));
vsb_delete(vsb);
diff --git a/bin/varnishd/mgt_cli.c b/bin/varnishd/mgt_cli.c
index 713d097..7618e97 100644
--- a/bin/varnishd/mgt_cli.c
+++ b/bin/varnishd/mgt_cli.c
@@ -420,7 +420,7 @@ mgt_cli_setup(int fdi, int fdo, int verbose, const char *ident, mgt_cli_close_f
cli->auth = MCF_AUTH;
mcf_banner(cli, NULL, NULL);
}
- vsb_finish(cli->sb);
+ AZ(vsb_finish(cli->sb));
(void)cli_writeres(fdo, cli);
@@ -449,8 +449,7 @@ sock_id(const char *pfx, int fd)
TCP_myname(fd, abuf1, sizeof abuf1, pbuf1, sizeof pbuf1);
TCP_hisname(fd, abuf2, sizeof abuf2, pbuf2, sizeof pbuf2);
vsb_printf(vsb, "%s %s %s %s %s", pfx, abuf2, pbuf2, abuf1, pbuf1);
- vsb_finish(vsb);
- AZ(vsb_error(vsb));
+ AZ(vsb_finish(vsb));
return (vsb);
}
@@ -583,8 +582,7 @@ mgt_cli_telnet(const char *T_arg)
REPORT(LOG_ERR, "-T %s could not be listened on.", T_arg);
exit(2);
}
- vsb_finish(vsb);
- AZ(vsb_error(vsb));
+ AZ(vsb_finish(vsb));
/* Save in shmem */
p = VSM_Alloc(vsb_len(vsb) + 1, "Arg", "-T", "");
AN(p);
diff --git a/bin/varnishd/mgt_vcc.c b/bin/varnishd/mgt_vcc.c
index 3ba8af3..17b49c6 100644
--- a/bin/varnishd/mgt_vcc.c
+++ b/bin/varnishd/mgt_vcc.c
@@ -117,8 +117,7 @@ mgt_make_cc_cmd(const char *sf, const char *of)
}
if (pct)
vsb_putc(sb, '%');
- vsb_finish(sb);
- AZ(vsb_error(sb));
+ AZ(vsb_finish(sb));
return (sb);
}
@@ -148,8 +147,7 @@ run_vcc(void *priv)
VCC_VMOD_dir(vcc, mgt_vmod_dir);
VCC_Err_Unref(vcc, mgt_vcc_err_unref);
csrc = VCC_Compile(vcc, sb, vp->vcl);
- vsb_finish(sb);
- AZ(vsb_error(sb));
+ AZ(vsb_finish(sb));
if (vsb_len(sb))
printf("%s", vsb_data(sb));
vsb_delete(sb);
@@ -302,8 +300,7 @@ mgt_VccCompile(struct vsb **sb, const char *b, int C_flag)
*sb = vsb_new_auto();
XXXAN(*sb);
vf = mgt_run_cc(b, *sb, C_flag);
- vsb_finish(*sb);
- AZ(vsb_error(*sb));
+ AZ(vsb_finish(*sb));
return (vf);
}
diff --git a/bin/varnishd/storage_synth.c b/bin/varnishd/storage_synth.c
index 02f58e6..74f22d2 100644
--- a/bin/varnishd/storage_synth.c
+++ b/bin/varnishd/storage_synth.c
@@ -112,8 +112,7 @@ SMS_Finish(struct object *obj)
sto = VTAILQ_FIRST(&obj->store);
assert(sto->stevedore == &sms_stevedore);
vsb = sto->priv;
- vsb_finish(vsb);
- AZ(vsb_error(vsb));
+ AZ(vsb_finish(vsb));
sto->ptr = (void*)vsb_data(vsb);
sto->len = vsb_len(vsb);
diff --git a/bin/varnishd/varnishd.c b/bin/varnishd/varnishd.c
index df64f18..3597867 100644
--- a/bin/varnishd/varnishd.c
+++ b/bin/varnishd/varnishd.c
@@ -229,8 +229,7 @@ cli_check(const struct cli *cli)
vsb_clear(cli->sb);
return;
}
- vsb_finish(cli->sb);
- AZ(vsb_error(cli->sb));
+ AZ(vsb_finish(cli->sb));
fprintf(stderr, "Error:\n%s\n", vsb_data(cli->sb));
exit (2);
}
@@ -534,8 +533,7 @@ main(int argc, char * const *argv)
/* XXX: we can have multiple CLI actions above, is this enough ? */
if (cli[0].result != CLIS_OK) {
fprintf(stderr, "Parameter errors:\n");
- vsb_finish(cli[0].sb);
- AZ(vsb_error(cli[0].sb));
+ AZ(vsb_finish(cli[0].sb));
fprintf(stderr, "%s\n", vsb_data(cli[0].sb));
exit(1);
}
@@ -622,8 +620,7 @@ main(int argc, char * const *argv)
mgt_SHM_Init(l_arg);
- vsb_finish(vident);
- AZ(vsb_error(vident));
+ AZ(vsb_finish(vident));
if (!d_flag && !F_flag)
AZ(varnish_daemon(1, 0));
diff --git a/bin/varnishlog/varnishlog.c b/bin/varnishlog/varnishlog.c
index 9659046..80771aa 100644
--- a/bin/varnishlog/varnishlog.c
+++ b/bin/varnishlog/varnishlog.c
@@ -85,7 +85,7 @@ static void
h_order_finish(int fd)
{
- vsb_finish(ob[fd]);
+ AZ(vsb_finish(ob[fd]));
if (vsb_len(ob[fd]) > 1 &&
(match_tag == -1 || flg[fd] & F_MATCH))
printf("%s\n", vsb_data(ob[fd]));
@@ -101,7 +101,7 @@ clean_order(void)
for (u = 0; u < 65536; u++) {
if (ob[u] == NULL)
continue;
- vsb_finish(ob[u]);
+ AZ(vsb_finish(ob[u]));
if (vsb_len(ob[u]) > 1 &&
(match_tag == -1 || flg[u] & F_MATCH))
printf("%s\n", vsb_data(ob[u]));
diff --git a/bin/varnishtest/vtc.c b/bin/varnishtest/vtc.c
index e374988..0a33ada 100644
--- a/bin/varnishtest/vtc.c
+++ b/bin/varnishtest/vtc.c
@@ -191,7 +191,7 @@ macro_expand(struct vtclog *vl, const char *text)
vsb_printf(vsb, "%s", m);
text = q + 1;
}
- vsb_finish(vsb);
+ AZ(vsb_finish(vsb));
return (vsb);
}
diff --git a/bin/varnishtest/vtc_http.c b/bin/varnishtest/vtc_http.c
index 95d41e8..486b656 100644
--- a/bin/varnishtest/vtc_http.c
+++ b/bin/varnishtest/vtc_http.c
@@ -141,8 +141,7 @@ http_write(const struct http *hp, int lvl, const char *pfx)
{
int l;
- vsb_finish(hp->vsb);
- AZ(vsb_error(hp->vsb));
+ AZ(vsb_finish(hp->vsb));
vtc_dump(hp->vl, lvl, pfx, vsb_data(hp->vsb), vsb_len(hp->vsb));
l = write(hp->fd, vsb_data(hp->vsb), vsb_len(hp->vsb));
if (l != vsb_len(hp->vsb))
diff --git a/bin/varnishtest/vtc_log.c b/bin/varnishtest/vtc_log.c
index bee6fe2..7e9c84c 100644
--- a/bin/varnishtest/vtc_log.c
+++ b/bin/varnishtest/vtc_log.c
@@ -140,8 +140,7 @@ vtc_log(struct vtclog *vl, unsigned lvl, const char *fmt, ...)
(void)vsb_vprintf(vl->vsb, fmt, ap);
va_end(ap);
vsb_putc(vl->vsb, '\n');
- vsb_finish(vl->vsb);
- AZ(vsb_error(vl->vsb));
+ AZ(vsb_finish(vl->vsb));
vtc_log_emit(vl, lvl);
@@ -211,8 +210,7 @@ vtc_dump(struct vtclog *vl, unsigned lvl, const char *pfx, const char *str, int
}
if (!nl)
vsb_printf(vl->vsb, "\n");
- vsb_finish(vl->vsb);
- AZ(vsb_error(vl->vsb));
+ AZ(vsb_finish(vl->vsb));
vtc_log_emit(vl, lvl);
@@ -266,8 +264,7 @@ vtc_hexdump(struct vtclog *vl, unsigned lvl, const char *pfx, const unsigned cha
}
if (!nl)
vsb_printf(vl->vsb, "\n");
- vsb_finish(vl->vsb);
- AZ(vsb_error(vl->vsb));
+ AZ(vsb_finish(vl->vsb));
vtc_log_emit(vl, lvl);
diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c
index c4a9477..4f9c668 100644
--- a/bin/varnishtest/vtc_varnish.c
+++ b/bin/varnishtest/vtc_varnish.c
@@ -158,7 +158,7 @@ varnish_new(const char *name)
v->storage = vsb_new_auto();
vsb_printf(v->storage, "-sfile,%s,10M", v->workdir);
- vsb_finish(v->storage);
+ AZ(vsb_finish(v->storage));
v->cli_fd = -1;
VTAILQ_INSERT_TAIL(&varnishes, v, list);
@@ -250,8 +250,7 @@ varnish_launch(struct varnish *v)
v->cli_fd = VSS_listen(ap[0], 1);
TCP_myname(v->cli_fd, abuf, sizeof abuf, pbuf, sizeof pbuf);
- vsb_finish(v->args);
- AZ(vsb_error(v->args));
+ AZ(vsb_finish(v->args));
vtc_log(v->vl, 2, "Launch");
vsb = vsb_new_auto();
AN(vsb);
@@ -266,8 +265,7 @@ varnish_launch(struct varnish *v)
vsb_printf(vsb, " -P %s/varnishd.pid", v->workdir);
vsb_printf(vsb, " %s", vsb_data(v->storage));
vsb_printf(vsb, " %s", vsb_data(v->args));
- vsb_finish(vsb);
- AZ(vsb_error(vsb));
+ AZ(vsb_finish(vsb));
vtc_log(v->vl, 3, "CMD: %s", vsb_data(vsb));
vsb1 = macro_expand(v->vl, vsb_data(vsb));
AN(vsb1);
@@ -514,8 +512,7 @@ varnish_vcl(struct varnish *v, const char *vcl, enum cli_status_e expect)
vsb_printf(vsb, "vcl.inline vcl%d << %s\n%s\n%s\n",
++v->vcl_nbr, NONSENSE, vcl, NONSENSE);
- vsb_finish(vsb);
- AZ(vsb_error(vsb));
+ AZ(vsb_finish(vsb));
u = varnish_ask_cli(v, vsb_data(vsb), NULL);
if (u != expect) {
@@ -528,8 +525,7 @@ varnish_vcl(struct varnish *v, const char *vcl, enum cli_status_e expect)
if (u == CLIS_OK) {
vsb_clear(vsb);
vsb_printf(vsb, "vcl.use vcl%d", v->vcl_nbr);
- vsb_finish(vsb);
- AZ(vsb_error(vsb));
+ AZ(vsb_finish(vsb));
u = varnish_ask_cli(v, vsb_data(vsb), NULL);
assert(u == CLIS_OK);
} else {
@@ -559,13 +555,11 @@ varnish_vclbackend(struct varnish *v, const char *vcl)
AN(vsb2);
cmd_server_genvcl(vsb2);
- vsb_finish(vsb2);
- AZ(vsb_error(vsb2));
+ AZ(vsb_finish(vsb2));
vsb_printf(vsb, "vcl.inline vcl%d << %s\n%s\n%s\n%s\n",
++v->vcl_nbr, NONSENSE, vsb_data(vsb2), vcl, NONSENSE);
- vsb_finish(vsb);
- AZ(vsb_error(vsb));
+ AZ(vsb_finish(vsb));
u = varnish_ask_cli(v, vsb_data(vsb), NULL);
if (u != CLIS_OK) {
@@ -576,8 +570,7 @@ varnish_vclbackend(struct varnish *v, const char *vcl)
}
vsb_clear(vsb);
vsb_printf(vsb, "vcl.use vcl%d", v->vcl_nbr);
- vsb_finish(vsb);
- AZ(vsb_error(vsb));
+ AZ(vsb_finish(vsb));
u = varnish_ask_cli(v, vsb_data(vsb), NULL);
assert(u == CLIS_OK);
vsb_delete(vsb);
@@ -712,7 +705,7 @@ cmd_varnish(CMD_ARGS)
if (!strcmp(*av, "-storage")) {
vsb_clear(v->storage);
vsb_cat(v->storage, av[1]);
- vsb_finish(v->storage);
+ AZ(vsb_finish(v->storage));
av++;
continue;
}
diff --git a/lib/libvarnish/cli_serve.c b/lib/libvarnish/cli_serve.c
index f727b0b..31bdfe6 100644
--- a/lib/libvarnish/cli_serve.c
+++ b/lib/libvarnish/cli_serve.c
@@ -289,8 +289,7 @@ cls_vlu2(void *priv, char * const *av)
}
} while (0);
- vsb_finish(cli->sb);
- AZ(vsb_error(cli->sb));
+ AZ(vsb_finish(cli->sb));
if (cs->after != NULL)
cs->after(cli);
@@ -359,8 +358,7 @@ cls_vlu(void *priv, const char *p)
vsb_cat(cfd->last_arg, "\n");
return (0);
}
- vsb_finish(cfd->last_arg);
- AZ(vsb_error(cfd->last_arg));
+ AZ(vsb_finish(cfd->last_arg));
free(cfd->argv[cfd->last_idx]);
cfd->argv[cfd->last_idx] = NULL;
free(cfd->argv[cfd->last_idx + 1]);
diff --git a/lib/libvcl/vcc_backend.c b/lib/libvcl/vcc_backend.c
index 0fe8608..e0e7279 100644
--- a/lib/libvcl/vcc_backend.c
+++ b/lib/libvcl/vcc_backend.c
@@ -602,8 +602,7 @@ vcc_ParseHostDef(struct vcc *tl, int serial, const char *vgcname)
vcc_NextToken(tl);
tl->fb = NULL;
- vsb_finish(vsb);
- AZ(vsb_error(vsb));
+ AZ(vsb_finish(vsb));
Fh(tl, 0, "%s", vsb_data(vsb));
vsb_delete(vsb);
diff --git a/lib/libvcl/vcc_compile.c b/lib/libvcl/vcc_compile.c
index df1d0e4..3a518b8 100644
--- a/lib/libvcl/vcc_compile.c
+++ b/lib/libvcl/vcc_compile.c
@@ -314,8 +314,7 @@ EmitInitFunc(const struct vcc *tl)
{
Fc(tl, 0, "\nstatic void\nVGC_Init(struct cli *cli)\n{\n\n");
- vsb_finish(tl->fi);
- AZ(vsb_error(tl->fi));
+ AZ(vsb_finish(tl->fi));
vsb_cat(tl->fc, vsb_data(tl->fi));
Fc(tl, 0, "}\n");
}
@@ -334,8 +333,7 @@ EmitFiniFunc(const struct vcc *tl)
for (u = 0; u < tl->nvmodpriv; u++)
Fc(tl, 0, "\tvmod_priv_fini(&vmod_priv_%u);\n", u);
- vsb_finish(tl->ff);
- AZ(vsb_error(tl->ff));
+ AZ(vsb_finish(tl->ff));
vsb_cat(tl->fc, vsb_data(tl->ff));
Fc(tl, 0, "}\n");
}
@@ -678,8 +676,7 @@ vcc_CompileSource(const struct vcc *tl0, struct vsb *sb, struct source *sp)
Fc(tl, 1, "\nstatic int\n");
Fc(tl, 1, "VGC_function_%s (struct sess *sp)\n",
method_tab[i].name);
- vsb_finish(tl->fm[i]);
- AZ(vsb_error(tl->fm[i]));
+ AZ(vsb_finish(tl->fm[i]));
Fc(tl, 1, "{\n");
Fc(tl, 1, "%s", vsb_data(tl->fm[i]));
Fc(tl, 1, "}\n");
@@ -694,11 +691,9 @@ vcc_CompileSource(const struct vcc *tl0, struct vsb *sb, struct source *sp)
EmitStruct(tl);
/* Combine it all in the fh vsb */
- vsb_finish(tl->fc);
- AZ(vsb_error(tl->fc));
+ AZ(vsb_finish(tl->fc));
vsb_cat(tl->fh, vsb_data(tl->fc));
- vsb_finish(tl->fh);
- AZ(vsb_error(tl->fh));
+ AZ(vsb_finish(tl->fh));
of = strdup(vsb_data(tl->fh));
AN(of);
diff --git a/lib/libvcl/vcc_dir_dns.c b/lib/libvcl/vcc_dir_dns.c
index 5d2c761..e24dcc4 100644
--- a/lib/libvcl/vcc_dir_dns.c
+++ b/lib/libvcl/vcc_dir_dns.c
@@ -120,7 +120,7 @@ print_backend(struct vcc *tl,
Fb(tl, 0, "};\n");
tl->fb = NULL;
- vsb_finish(vsb);
+ AZ(vsb_finish(vsb));
Fh(tl, 0, "%s", vsb_data(vsb));
vsb_delete(vsb);
Fi(tl, 0, "\tVRT_init_dir(cli, VCL_conf.director, \"simple\",\n"
diff --git a/lib/libvcl/vcc_expr.c b/lib/libvcl/vcc_expr.c
index 1c14503..659b8b9 100644
--- a/lib/libvcl/vcc_expr.c
+++ b/lib/libvcl/vcc_expr.c
@@ -269,8 +269,7 @@ vcc_mk_expr(enum var_type fmt, const char *str, ...)
va_start(ap, str);
vsb_vprintf(e->vsb, str, ap);
va_end(ap);
- vsb_finish(e->vsb);
- AZ(vsb_error(e->vsb));
+ AZ(vsb_finish(e->vsb));
return (e);
}
@@ -345,8 +344,7 @@ vcc_expr_edit(enum var_type fmt, const char *p, struct expr *e1,
}
p++;
}
- vsb_finish(e->vsb);
- AZ(vsb_error(e->vsb));
+ AZ(vsb_finish(e->vsb));
if (e1 != NULL)
e->t1 = e1->t1;
else if (e2 != NULL)
@@ -696,8 +694,7 @@ vcc_expr4(struct vcc *tl, struct expr **e, enum var_type fmt)
e1->t1 = tl->t;
e1->constant = 1;
vcc_NextToken(tl);
- vsb_finish(e1->vsb);
- AZ(vsb_error(e1->vsb));
+ AZ(vsb_finish(e1->vsb));
*e = e1;
break;
case CNUM:
More information about the varnish-commit
mailing list