From 3fc78d15e8213296d0e9fa76ff3b6b1fc41b3088 Mon Sep 17 00:00:00 2001 From: phk Date: Fri, 21 Jul 2006 21:01:45 +0000 Subject: [PATCH] Update VRT to minimal functional level again git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@549 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- varnish-cache/bin/varnishd/cache_vrt.c | 85 ++++++++++++++++++++++---- varnish-cache/include/vrt.h | 7 --- 2 files changed, 72 insertions(+), 20 deletions(-) diff --git a/varnish-cache/bin/varnishd/cache_vrt.c b/varnish-cache/bin/varnishd/cache_vrt.c index d913c589..0d3596f3 100644 --- a/varnish-cache/bin/varnishd/cache_vrt.c +++ b/varnish-cache/bin/varnishd/cache_vrt.c @@ -11,6 +11,7 @@ #include "shmlog.h" #include "vrt.h" +#include "vrt_obj.h" #include "vcl.h" #include "cache.h" @@ -74,32 +75,34 @@ VRT_handling(struct sess *sp, unsigned hand) sp->handling = hand; } -int -VRT_obj_valid(struct sess *sp) +/*--------------------------------------------------------------------*/ + +void +VRT_l_backend_host(struct backend *be, const char *h) { - CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); - return (sp->obj->valid); + CHECK_OBJ_NOTNULL(be, BACKEND_MAGIC); + be->hostname = h; } -int -VRT_obj_cacheable(struct sess *sp) +const char * +VRT_r_backend_host(struct backend *be) { - CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); - return (sp->obj->cacheable); + CHECK_OBJ_NOTNULL(be, BACKEND_MAGIC); + return (be->hostname); } void -VRT_set_backend_hostname(struct backend *be, const char *h) +VRT_l_backend_port(struct backend *be, const char *p) { CHECK_OBJ_NOTNULL(be, BACKEND_MAGIC); - be->hostname = h; + be->portname = p; } -void -VRT_set_backend_portname(struct backend *be, const char *p) +const char * +VRT_r_backend_port(struct backend *be) { CHECK_OBJ_NOTNULL(be, BACKEND_MAGIC); - be->portname = p; + return (be->portname); } void @@ -122,3 +125,59 @@ VRT_alloc_backends(struct VCL_conf *cp) cp->backend[i]->magic = BACKEND_MAGIC; } } + +/*--------------------------------------------------------------------*/ + +void +VRT_l_obj_ttl(struct sess *sp, double a) +{ + + CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); + (void)a; +} + +double +VRT_r_obj_ttl(struct sess *sp) +{ + CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); + CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC); /* XXX */ + return (sp->obj->ttl - sp->t_req); +} + + +double +VRT_r_obj_valid(struct sess *sp) +{ + CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); + CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC); /* XXX */ + return (sp->obj->valid); +} + + +double +VRT_r_obj_cacheable(struct sess *sp) +{ + CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); + CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC); /* XXX */ + return (sp->obj->cacheable); +} + +/*--------------------------------------------------------------------*/ + +const char * +VRT_r_req_request(struct sess *sp) +{ + CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); + CHECK_OBJ_NOTNULL(sp->http, HTTP_MAGIC); + return (sp->http->hd[HTTP_HDR_REQ].b); +} + + +const char * +VRT_r_req_url(struct sess *sp) +{ + CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); + CHECK_OBJ_NOTNULL(sp->http, HTTP_MAGIC); + return (sp->http->hd[HTTP_HDR_URL].b); +} + diff --git a/varnish-cache/include/vrt.h b/varnish-cache/include/vrt.h index 62b291e4..69cfe852 100644 --- a/varnish-cache/include/vrt.h +++ b/varnish-cache/include/vrt.h @@ -24,8 +24,6 @@ struct vrt_acl { }; void VRT_count(struct sess *, unsigned); -void VRT_no_cache(struct sess *); -void VRT_no_new_cache(struct sess *); #if 0 int ip_match(unsigned, struct vcl_acl *); int string_match(const char *, const char *); @@ -35,14 +33,9 @@ void VRT_error(struct sess *, unsigned, const char *); int VRT_switch_config(const char *); char *VRT_GetHdr(struct sess *, const char *); -char *VRT_GetReq(struct sess *); void VRT_handling(struct sess *sp, unsigned hand); -int VRT_obj_valid(struct sess *); -int VRT_obj_cacheable(struct sess *); void VRT_set_backend_name(struct backend *, const char *); -void VRT_set_backend_hostname(struct backend *, const char *); -void VRT_set_backend_portname(struct backend *, const char *); void VRT_alloc_backends(struct VCL_conf *cp); -- 2.39.5