From 32e8b9e6c2e395cf88a6b4fa0dc4d41782fcbbd9 Mon Sep 17 00:00:00 2001 From: phk Date: Mon, 25 Jun 2007 07:14:08 +0000 Subject: [PATCH] Add bitmap of methods where they are valid to all objects. git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@1551 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- varnish-cache/lib/libvcl/vcc_compile.h | 1 + varnish-cache/lib/libvcl/vcc_gen_obj.tcl | 65 +++++++++++++++++++----- varnish-cache/lib/libvcl/vcc_obj.c | 56 ++++++++++++-------- 3 files changed, 88 insertions(+), 34 deletions(-) diff --git a/varnish-cache/lib/libvcl/vcc_compile.h b/varnish-cache/lib/libvcl/vcc_compile.h index 4b5898d0..d6ec1437 100644 --- a/varnish-cache/lib/libvcl/vcc_compile.h +++ b/varnish-cache/lib/libvcl/vcc_compile.h @@ -121,6 +121,7 @@ struct var { const char *rname; const char *lname; unsigned has_string; + unsigned methods; }; struct method { diff --git a/varnish-cache/lib/libvcl/vcc_gen_obj.tcl b/varnish-cache/lib/libvcl/vcc_gen_obj.tcl index b188fbbe..f47bb54f 100755 --- a/varnish-cache/lib/libvcl/vcc_gen_obj.tcl +++ b/varnish-cache/lib/libvcl/vcc_gen_obj.tcl @@ -40,19 +40,45 @@ set beobj { # Objects which operate on sessions set spobj { - { client.ip IP 1} - { server.ip IP 1} - { req.request STRING 1} - { req.host STRING 1} - { req.url STRING 1} - { req.proto STRING 1} - { req.backend BACKEND 0} - { req.hash HASH 0} - { obj.valid BOOL 0} - { obj.cacheable BOOL 0} - { obj.ttl TIME 0} - { req.http. HEADER 1} - { resp.http. HEADER 1} + { client.ip IP 1 + {recv pipe pass hash miss hit fetch} + } + { server.ip IP 1 + {recv pipe pass hash miss hit fetch} + } + { req.request STRING 1 + {recv pipe pass hash miss hit fetch} + } + { req.host STRING 1 + {recv pipe pass hash miss hit fetch} + } + { req.url STRING 1 + {recv pipe pass hash miss hit fetch} + } + { req.proto STRING 1 + {recv pipe pass hash miss hit fetch} + } + { req.backend BACKEND 0 + {recv pipe pass hash miss hit fetch} + } + { req.http. HEADER 1 + {recv pipe pass hash miss hit fetch} + } + { req.hash HASH 0 + {hash} + } + { obj.valid BOOL 0 + {hit fetch} + } + { obj.cacheable BOOL 0 + {hit fetch} + } + { obj.ttl TIME 0 + {hit fetch} + } + { resp.http. HEADER 1 + {fetch} + } } set tt(IP) "struct sockaddr *" @@ -85,6 +111,16 @@ warns $fo set fp [open ../../include/vrt_obj.h w] warns $fp +proc method_map {m} { + + set l "" + foreach i $m { + append l " | " + append l VCL_MET_[string toupper $i] + } + return [string range $l 3 end] +} + proc vars {v ty pa} { global tt fo fp @@ -95,7 +131,8 @@ proc vars {v ty pa} { puts $fo "\t\{ \"$n\", $t, [string length $n]," puts $fo "\t \"VRT_r_${m}($pa)\"," puts $fo "\t \"VRT_l_${m}($pa, \"," - puts $fo "\t [lindex $v 2]" + puts $fo "\t [lindex $v 2], " + puts $fo "\t [method_map [lindex $v 3]]" puts $fo "\t\}," puts $fp "$tt($t) VRT_r_${m}($ty);" diff --git a/varnish-cache/lib/libvcl/vcc_obj.c b/varnish-cache/lib/libvcl/vcc_obj.c index d5a74953..593e5388 100644 --- a/varnish-cache/lib/libvcl/vcc_obj.c +++ b/varnish-cache/lib/libvcl/vcc_obj.c @@ -13,17 +13,20 @@ struct var vcc_be_vars[] = { { "backend.host", HOSTNAME, 12, "VRT_r_backend_host(backend)", "VRT_l_backend_host(backend, ", - 0 + 0, + }, { "backend.port", PORTNAME, 12, "VRT_r_backend_port(backend)", "VRT_l_backend_port(backend, ", - 0 + 0, + }, { "backend.dnsttl", TIME, 14, "VRT_r_backend_dnsttl(backend)", "VRT_l_backend_dnsttl(backend, ", - 0 + 0, + }, { NULL } }; @@ -32,67 +35,80 @@ struct var vcc_vars[] = { { "client.ip", IP, 9, "VRT_r_client_ip(sp)", "VRT_l_client_ip(sp, ", - 1 + 1, + VCL_MET_RECV | VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_HASH | VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH }, { "server.ip", IP, 9, "VRT_r_server_ip(sp)", "VRT_l_server_ip(sp, ", - 1 + 1, + VCL_MET_RECV | VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_HASH | VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH }, { "req.request", STRING, 11, "VRT_r_req_request(sp)", "VRT_l_req_request(sp, ", - 1 + 1, + VCL_MET_RECV | VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_HASH | VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH }, { "req.host", STRING, 8, "VRT_r_req_host(sp)", "VRT_l_req_host(sp, ", - 1 + 1, + VCL_MET_RECV | VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_HASH | VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH }, { "req.url", STRING, 7, "VRT_r_req_url(sp)", "VRT_l_req_url(sp, ", - 1 + 1, + VCL_MET_RECV | VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_HASH | VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH }, { "req.proto", STRING, 9, "VRT_r_req_proto(sp)", "VRT_l_req_proto(sp, ", - 1 + 1, + VCL_MET_RECV | VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_HASH | VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH }, { "req.backend", BACKEND, 11, "VRT_r_req_backend(sp)", "VRT_l_req_backend(sp, ", - 0 + 0, + VCL_MET_RECV | VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_HASH | VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH + }, + { "req.http.", HEADER, 9, + "VRT_r_req_http_(sp)", + "VRT_l_req_http_(sp, ", + 1, + VCL_MET_RECV | VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_HASH | VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH }, { "req.hash", HASH, 8, "VRT_r_req_hash(sp)", "VRT_l_req_hash(sp, ", - 0 + 0, + VCL_MET_HASH }, { "obj.valid", BOOL, 9, "VRT_r_obj_valid(sp)", "VRT_l_obj_valid(sp, ", - 0 + 0, + VCL_MET_HIT | VCL_MET_FETCH }, { "obj.cacheable", BOOL, 13, "VRT_r_obj_cacheable(sp)", "VRT_l_obj_cacheable(sp, ", - 0 + 0, + VCL_MET_HIT | VCL_MET_FETCH }, { "obj.ttl", TIME, 7, "VRT_r_obj_ttl(sp)", "VRT_l_obj_ttl(sp, ", - 0 - }, - { "req.http.", HEADER, 9, - "VRT_r_req_http_(sp)", - "VRT_l_req_http_(sp, ", - 1 + 0, + VCL_MET_HIT | VCL_MET_FETCH }, { "resp.http.", HEADER, 10, "VRT_r_resp_http_(sp)", "VRT_l_resp_http_(sp, ", - 1 + 1, + VCL_MET_FETCH }, { NULL } }; -- 2.39.5