[master] f492465 Replace the newly introduced "ws" argument to VCL/VRT, with the even newer vrt_ctx argument.
Poul-Henning Kamp
phk at varnish-cache.org
Tue Apr 30 12:25:07 CEST 2013
commit f4924656a137ea5cfe14e8c0fdfb606f57844a05
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Tue Apr 30 10:24:27 2013 +0000
Replace the newly introduced "ws" argument to VCL/VRT, with the
even newer vrt_ctx argument.
diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c
index d17d6aa..cb7f095 100644
--- a/bin/varnishd/cache/cache_vcl.c
+++ b/bin/varnishd/cache/cache_vcl.c
@@ -220,7 +220,7 @@ VCL_Load(const char *fn, const char *name, struct cli *cli)
REPLACE(vcl->name, name);
VCLI_Out(cli, "Loaded \"%s\" as \"%s\"", fn , name);
VTAILQ_INSERT_TAIL(&vcl_head, vcl, list);
- (void)vcl->conf->init_func(&ctx, NULL, NULL, NULL, NULL);
+ (void)vcl->conf->init_func(&ctx, NULL, NULL, NULL);
Lck_Lock(&vcl_mtx);
if (vcl_active == NULL)
vcl_active = vcl;
@@ -247,7 +247,7 @@ VCL_Nuke(struct vcls *vcl)
assert(vcl->conf->discard);
assert(vcl->conf->busy == 0);
VTAILQ_REMOVE(&vcl_head, vcl, list);
- (void)vcl->conf->fini_func(&ctx, NULL, NULL, NULL, NULL);
+ (void)vcl->conf->fini_func(&ctx, NULL, NULL, NULL);
vcl->conf->fini_vcl(NULL);
free(vcl->name);
(void)dlclose(vcl->dlh);
@@ -419,7 +419,7 @@ vcl_call_method(struct worker *wrk, struct req *req, struct busyobj *bo,
wrk->cur_method = method;
AN(vsl);
VSLb(vsl, SLT_VCL_call, "%s", VCL_Method_Name(method));
- (void)func(&ctx, wrk, req, bo, ws);
+ (void)func(&ctx, wrk, req, bo);
VSLb(vsl, SLT_VCL_return, "%s", VCL_Return_Name(wrk->handling));
wrk->cur_method = 0;
WS_Reset(wrk->aws, aws);
diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c
index 8d361b1..58b7df1 100644
--- a/bin/varnishd/cache/cache_vrt.c
+++ b/bin/varnishd/cache/cache_vrt.c
@@ -214,14 +214,15 @@ VRT_String(struct ws *ws, const char *h, const char *p, va_list ap)
*/
const char *
-VRT_CollectString(struct ws *ws, const char *p, ...)
+VRT_CollectString(const struct vrt_ctx *ctx, const char *p, ...)
{
va_list ap;
char *b;
- CHECK_OBJ_NOTNULL(ws, WS_MAGIC);
+ CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
+ CHECK_OBJ_NOTNULL(ctx->ws, WS_MAGIC);
va_start(ap, p);
- b = VRT_String(ws, NULL, p, ap);
+ b = VRT_String(ctx->ws, NULL, p, ap);
va_end(ap);
return (b);
}
@@ -303,7 +304,7 @@ VRT_r_now()
/*--------------------------------------------------------------------*/
char *
-VRT_IP_string(struct ws *ws, const struct sockaddr_storage *sa)
+VRT_IP_string(const struct vrt_ctx *ctx, const struct sockaddr_storage *sa)
{
char *p;
const struct sockaddr_in *si4;
@@ -311,7 +312,7 @@ VRT_IP_string(struct ws *ws, const struct sockaddr_storage *sa)
const void *addr;
int len;
- CHECK_OBJ_NOTNULL(ws, WS_MAGIC);
+ CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
switch (sa->ss_family) {
case AF_INET:
len = INET_ADDRSTRLEN;
@@ -327,44 +328,44 @@ VRT_IP_string(struct ws *ws, const struct sockaddr_storage *sa)
INCOMPL();
}
XXXAN(len);
- AN(p = WS_Alloc(ws, len));
+ AN(p = WS_Alloc(ctx->ws, len));
AN(inet_ntop(sa->ss_family, addr, p, len));
return (p);
}
char *
-VRT_INT_string(struct ws *ws, long num)
+VRT_INT_string(const struct vrt_ctx *ctx, long num)
{
char *p;
int size;
- CHECK_OBJ_NOTNULL(ws, WS_MAGIC);
+ CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
size = snprintf(NULL, 0, "%ld", num) + 1;
- AN(p = WS_Alloc(ws, size));
+ AN(p = WS_Alloc(ctx->ws, size));
assert(snprintf(p, size, "%ld", num) < size);
return (p);
}
char *
-VRT_REAL_string(struct ws *ws, double num)
+VRT_REAL_string(const struct vrt_ctx *ctx, double num)
{
char *p;
int size;
- CHECK_OBJ_NOTNULL(ws, WS_MAGIC);
+ CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
size = snprintf(NULL, 0, "%.3f", num) + 1;
- AN(p = WS_Alloc(ws, size));
+ AN(p = WS_Alloc(ctx->ws, size));
assert(snprintf(p, size, "%.3f", num) < size);
return (p);
}
char *
-VRT_TIME_string(struct ws *ws, double t)
+VRT_TIME_string(const struct vrt_ctx *ctx, double t)
{
char *p;
- CHECK_OBJ_NOTNULL(ws, WS_MAGIC);
- p = WS_Alloc(ws, VTIM_FORMAT_SIZE);
+ CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
+ p = WS_Alloc(ctx->ws, VTIM_FORMAT_SIZE);
if (p != NULL)
VTIM_format(t, p);
return (p);
diff --git a/include/vrt.h b/include/vrt.h
index 2e230ad..031a9e1 100644
--- a/include/vrt.h
+++ b/include/vrt.h
@@ -251,11 +251,11 @@ int VRT_Stv(const char *nm);
/* Convert things to string */
-char *VRT_IP_string(struct ws *, const struct sockaddr_storage *sa);
-char *VRT_INT_string(struct ws *, long);
-char *VRT_REAL_string(struct ws *, double);
-char *VRT_TIME_string(struct ws *, double);
+char *VRT_IP_string(const struct vrt_ctx *, const struct sockaddr_storage *sa);
+char *VRT_INT_string(const struct vrt_ctx *, long);
+char *VRT_REAL_string(const struct vrt_ctx *, double);
+char *VRT_TIME_string(const struct vrt_ctx *, double);
const char *VRT_BOOL_string(unsigned);
const char *VRT_BACKEND_string(const struct director *d);
-const char *VRT_CollectString(struct ws *, const char *p, ...);
+const char *VRT_CollectString(const struct vrt_ctx *, const char *p, ...);
diff --git a/lib/libvcl/generate.py b/lib/libvcl/generate.py
index 140635b..6ef580b 100755
--- a/lib/libvcl/generate.py
+++ b/lib/libvcl/generate.py
@@ -774,8 +774,7 @@ struct worker;
typedef int vcl_init_f(struct cli *);
typedef void vcl_fini_f(struct cli *);
-typedef int vcl_func_f(struct vrt_ctx *ctx, struct worker *, struct req *, struct busyobj *,
- struct ws *);
+typedef int vcl_func_f(const struct vrt_ctx *ctx, struct worker *, struct req *, struct busyobj *);
""")
diff --git a/lib/libvcl/vcc_compile.c b/lib/libvcl/vcc_compile.c
index d6dd786..4520b00 100644
--- a/lib/libvcl/vcc_compile.c
+++ b/lib/libvcl/vcc_compile.c
@@ -693,8 +693,9 @@ vcc_CompileSource(const struct vcc *tl0, struct vsb *sb, struct source *sp)
for (i = 0; i < VCL_MET_MAX; i++) {
Fc(tl, 1, "\nstatic int __match_proto__(vcl_func_f)\n");
Fc(tl, 1,
- "VGC_function_%s(struct vrt_ctx *ctx, struct worker *wrk,"
- " struct req *req, struct busyobj *bo, struct ws *ws)\n",
+ "VGC_function_%s(const struct vrt_ctx *ctx,"
+ " struct worker *wrk,"
+ " struct req *req, struct busyobj *bo)\n",
method_tab[i].name);
AZ(VSB_finish(tl->fm[i]));
Fc(tl, 1, "{\n");
diff --git a/lib/libvcl/vcc_expr.c b/lib/libvcl/vcc_expr.c
index ab3175e..c318920 100644
--- a/lib/libvcl/vcc_expr.c
+++ b/lib/libvcl/vcc_expr.c
@@ -404,20 +404,20 @@ vcc_expr_tostring(struct expr **e, enum var_type fmt)
switch((*e)->fmt) {
case BACKEND: p = "VRT_BACKEND_string(\v1)"; break;
case BOOL: p = "VRT_BOOL_string(\v1)"; break;
- case DURATION: p = "VRT_REAL_string(ws, \v1)"; break;
+ case DURATION: p = "VRT_REAL_string(ctx, \v1)"; break;
/* XXX: should DURATION insist on "s" suffix ? */
case INT:
if (vcc_isconst(*e)) {
p = "\"\v1\"";
constant = EXPR_CONST;
} else {
- p = "VRT_INT_string(ws, \v1)";
+ p = "VRT_INT_string(ctx, \v1)";
}
break;
- case IP: p = "VRT_IP_string(ws, \v1)"; break;
- case BYTES: p = "VRT_REAL_string(ws, \v1)"; break; /* XXX */
- case REAL: p = "VRT_REAL_string(ws, \v1)"; break;
- case TIME: p = "VRT_TIME_string(ws, \v1)"; break;
+ case IP: p = "VRT_IP_string(ctx, \v1)"; break;
+ case BYTES: p = "VRT_REAL_string(ctx, \v1)"; break; /* XXX */
+ case REAL: p = "VRT_REAL_string(ctx, \v1)"; break;
+ case TIME: p = "VRT_TIME_string(ctx, \v1)"; break;
case HEADER: p = "VRT_GetHdr(ctx, \v1)"; break;
case ENUM:
case STRING:
@@ -914,7 +914,7 @@ vcc_expr_strfold(struct vcc *tl, struct expr **e, enum var_type fmt)
if (fmt != STRING_LIST && (*e)->fmt == STRING_LIST)
*e = vcc_expr_edit(STRING,
- "\v+VRT_CollectString(ws,\n\v1,\nvrt_magic_string_end)\v-",
+ "\v+VRT_CollectString(ctx,\n\v1,\nvrt_magic_string_end)\v-",
*e, NULL);
if (fmt == STRING_LIST && (*e)->fmt == STRING)
(*e)->fmt = STRING_LIST;
More information about the varnish-commit
mailing list