r5001 - in trunk/varnish-cache: bin/varnishd bin/varnishtest/tests include lib/libvcl
phk at varnish-cache.org
phk at varnish-cache.org
Sun Jul 4 16:40:34 CEST 2010
Author: phk
Date: 2010-07-04 16:40:33 +0200 (Sun, 04 Jul 2010)
New Revision: 5001
Modified:
trunk/varnish-cache/bin/varnishd/cache_vrt.c
trunk/varnish-cache/bin/varnishd/default.vcl
trunk/varnish-cache/bin/varnishtest/tests/r00693.vtc
trunk/varnish-cache/bin/varnishtest/tests/v00018.vtc
trunk/varnish-cache/include/vrt.h
trunk/varnish-cache/include/vrt_obj.h
trunk/varnish-cache/lib/libvcl/generate.py
trunk/varnish-cache/lib/libvcl/vcc_action.c
trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c
trunk/varnish-cache/lib/libvcl/vcc_obj.c
Log:
Convert the "req.hash +=" pseudo variable handing of the
hask-key build process to look like a function call instead:
hash_data(req.http.foo_bar)
and allow string concatenation while we're at it.
the name "hash_data()" is not quite to my liking, but I want to avoid
"hash()" since that clashes with previous syntax for "return(hash)".
Modified: trunk/varnish-cache/bin/varnishd/cache_vrt.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_vrt.c 2010-07-04 14:15:28 UTC (rev 5000)
+++ trunk/varnish-cache/bin/varnishd/cache_vrt.c 2010-07-04 14:40:33 UTC (rev 5001)
@@ -747,10 +747,19 @@
*/
void
-VRT_l_req_hash(struct sess *sp, const char *str)
+VRT_hashdata(struct sess *sp, const char *str, ...)
{
+ va_list ap;
+ const char *p;
HSH_AddString(sp, str);
+ va_start(ap, str);
+ while (1) {
+ p = va_arg(ap, const char *);
+ if (p == vrt_magic_string_end)
+ break;
+ HSH_AddString(sp, p);
+ }
}
/*--------------------------------------------------------------------*/
Modified: trunk/varnish-cache/bin/varnishd/default.vcl
===================================================================
--- trunk/varnish-cache/bin/varnishd/default.vcl 2010-07-04 14:15:28 UTC (rev 5000)
+++ trunk/varnish-cache/bin/varnishd/default.vcl 2010-07-04 14:40:33 UTC (rev 5001)
@@ -82,11 +82,11 @@
}
sub vcl_hash {
- set req.hash += req.url;
+ hash_data(req.url);
if (req.http.host) {
- set req.hash += req.http.host;
+ hash_data(req.http.host);
} else {
- set req.hash += server.ip;
+ hash_data(server.ip);
}
return (hash);
}
Modified: trunk/varnish-cache/bin/varnishtest/tests/r00693.vtc
===================================================================
--- trunk/varnish-cache/bin/varnishtest/tests/r00693.vtc 2010-07-04 14:15:28 UTC (rev 5000)
+++ trunk/varnish-cache/bin/varnishtest/tests/r00693.vtc 2010-07-04 14:40:33 UTC (rev 5001)
@@ -60,7 +60,7 @@
return (pass);
}
sub vcl_hash {
- set req.hash += req.url;
+ hash_data(req.url);
return (hash);
}
} -start
Modified: trunk/varnish-cache/bin/varnishtest/tests/v00018.vtc
===================================================================
--- trunk/varnish-cache/bin/varnishtest/tests/v00018.vtc 2010-07-04 14:15:28 UTC (rev 5000)
+++ trunk/varnish-cache/bin/varnishtest/tests/v00018.vtc 2010-07-04 14:40:33 UTC (rev 5001)
@@ -53,7 +53,7 @@
varnish v1 -badvcl {
backend b { .host = "127.0.0.1"; }
- sub vcl_hash { set req.hash += 1; }
+ sub vcl_hash { hash_data(req.hash); }
}
varnish v1 -badvcl {
Modified: trunk/varnish-cache/include/vrt.h
===================================================================
--- trunk/varnish-cache/include/vrt.h 2010-07-04 14:15:28 UTC (rev 5000)
+++ trunk/varnish-cache/include/vrt.h 2010-07-04 14:40:33 UTC (rev 5001)
@@ -150,6 +150,8 @@
const char *, ...);
void VRT_handling(struct sess *sp, unsigned hand);
+void VRT_hashdata(struct sess *sp, const char *str, ...);
+
/* Simple stuff */
int VRT_strcmp(const char *s1, const char *s2);
void VRT_memmove(void *dst, const void *src, unsigned len);
Modified: trunk/varnish-cache/include/vrt_obj.h
===================================================================
--- trunk/varnish-cache/include/vrt_obj.h 2010-07-04 14:15:28 UTC (rev 5000)
+++ trunk/varnish-cache/include/vrt_obj.h 2010-07-04 14:40:33 UTC (rev 5001)
@@ -17,7 +17,6 @@
void VRT_l_req_url(const struct sess *, const char *, ...);
const char * VRT_r_req_proto(const struct sess *);
void VRT_l_req_proto(const struct sess *, const char *, ...);
-void VRT_l_req_hash(struct sess *, const char *);
struct director * VRT_r_req_backend(struct sess *);
void VRT_l_req_backend(struct sess *, struct director *);
int VRT_r_req_restarts(const struct sess *);
Modified: trunk/varnish-cache/lib/libvcl/generate.py
===================================================================
--- trunk/varnish-cache/lib/libvcl/generate.py 2010-07-04 14:15:28 UTC (rev 5000)
+++ trunk/varnish-cache/lib/libvcl/generate.py 2010-07-04 14:40:33 UTC (rev 5001)
@@ -148,12 +148,6 @@
( 'all',),
'const struct sess *'
),
- ('req.hash',
- 'HASH',
- ( ),
- ( 'hash', 'error',), # XXX error ???
- 'struct sess *'
- ),
('req.backend',
'BACKEND',
( 'all',),
@@ -378,7 +372,6 @@
'DURATION': "double",
'INT': "int",
'HEADER': "const char *",
- 'HASH': "const char *",
}
#######################################################################
Modified: trunk/varnish-cache/lib/libvcl/vcc_action.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_action.c 2010-07-04 14:15:28 UTC (rev 5000)
+++ trunk/varnish-cache/lib/libvcl/vcc_action.c 2010-07-04 14:40:33 UTC (rev 5001)
@@ -400,6 +400,26 @@
/*--------------------------------------------------------------------*/
static void
+parse_hash_data(struct vcc *tl)
+{
+ vcc_NextToken(tl);
+ SkipToken(tl, '(');
+
+ Fb(tl, 1, "VRT_hashdata(sp, ");
+ if (!vcc_StringVal(tl)) {
+ vcc_ExpectedStringval(tl);
+ return;
+ }
+ do
+ Fb(tl, 0, ", ");
+ while (vcc_StringVal(tl));
+ Fb(tl, 0, " vrt_magic_string_end);\n");
+ SkipToken(tl, ')');
+}
+
+/*--------------------------------------------------------------------*/
+
+static void
parse_panic(struct vcc *tl)
{
vcc_NextToken(tl);
@@ -494,6 +514,7 @@
/* Keep list sorted from here */
{ "call", parse_call },
{ "esi", parse_esi, VCL_MET_FETCH },
+ { "hash_data", parse_hash_data, VCL_MET_HASH },
{ "panic", parse_panic },
{ "purge", parse_purge },
{ "purge_url", parse_purge_url },
Modified: trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c 2010-07-04 14:15:28 UTC (rev 5000)
+++ trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c 2010-07-04 14:40:33 UTC (rev 5001)
@@ -315,10 +315,11 @@
/* ../../include/vrt_obj.h */
- vsb_cat(sb, "\n/*\n * $Id$\n *\n * NB: This file is machine "
- "generated, DO NOT EDIT!\n *\n * Edit and run generate.py instead"
- "\n */\nstruct sockaddr * VRT_r_client_ip(const struct sess "
- "*);\nstruct sockaddr * VRT_r_server_ip(struct sess *);\n"
+ vsb_cat(sb, "\n/*\n * $Id: vrt_obj.h 5000 2010-07-04 14:15:28Z "
+ "phk $\n *\n * NB: This file is machine generated, DO NOT "
+ "EDIT!\n *\n * Edit and run generate.py instead\n */\n"
+ "struct sockaddr * VRT_r_client_ip(const struct sess *);\n"
+ "struct sockaddr * VRT_r_server_ip(struct sess *);\n"
"const char * VRT_r_server_hostname(struct sess *);\n"
"const char * VRT_r_server_identity(struct sess *);\n"
"int VRT_r_server_port(struct sess *);\nconst char * VRT_r_req_re"
Modified: trunk/varnish-cache/lib/libvcl/vcc_obj.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_obj.c 2010-07-04 14:15:28 UTC (rev 5000)
+++ trunk/varnish-cache/lib/libvcl/vcc_obj.c 2010-07-04 14:40:33 UTC (rev 5001)
@@ -101,13 +101,6 @@
| VCL_MET_ERROR,
"HDR_REQ",
},
- { "req.hash", HASH, 8,
- NULL, /* No reads allowed */
- 0,
- "VRT_l_req_hash(sp, ",
- VCL_MET_HASH | VCL_MET_ERROR,
- 0,
- },
{ "req.backend", BACKEND, 11,
"VRT_r_req_backend(sp)",
VCL_MET_RECV | VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_HASH
More information about the varnish-commit
mailing list