From a19445f57f9e27abf63c143d18c3495653446aea Mon Sep 17 00:00:00 2001 From: phk Date: Tue, 20 Jun 2006 09:41:43 +0000 Subject: [PATCH] Work towards making struct sess opaque to the generated code. git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@210 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- varnish-cache/bin/varnishd/cache_vrt.c | 9 +++++++++ varnish-cache/include/vcl_lang.h | 4 +--- varnish-cache/include/vrt.h | 8 ++++---- varnish-cache/lib/libvcl/vcl_compile.c | 15 ++++++--------- varnish-cache/lib/libvcl/vcl_fixed_token.c | 12 +++++------- 5 files changed, 25 insertions(+), 23 deletions(-) diff --git a/varnish-cache/bin/varnishd/cache_vrt.c b/varnish-cache/bin/varnishd/cache_vrt.c index ef68cdae..33c6c78b 100644 --- a/varnish-cache/bin/varnishd/cache_vrt.c +++ b/varnish-cache/bin/varnishd/cache_vrt.c @@ -67,3 +67,12 @@ VRT_GetReq(struct sess *sp) assert(http_GetReq(sp->http, &p)); return (p); } + +/*--------------------------------------------------------------------*/ + +void +VRT_handling(struct sess *sp, enum handling hand) +{ + + sp->handling = hand; +} diff --git a/varnish-cache/include/vcl_lang.h b/varnish-cache/include/vcl_lang.h index 20fc6a72..fed7dd7a 100644 --- a/varnish-cache/include/vcl_lang.h +++ b/varnish-cache/include/vcl_lang.h @@ -47,8 +47,6 @@ struct sess { enum handling handling; - char done; - TAILQ_ENTRY(sess) list; sesscb_f *sesscb; @@ -82,7 +80,7 @@ int string_match(const char *, const char *); #endif typedef void vcl_init_f(void); -typedef void vcl_func_f(struct sess *sp); +typedef int vcl_func_f(struct sess *sp); struct VCL_conf { unsigned magic; diff --git a/varnish-cache/include/vrt.h b/varnish-cache/include/vrt.h index 936f46be..a3a24b66 100644 --- a/varnish-cache/include/vrt.h +++ b/varnish-cache/include/vrt.h @@ -31,10 +31,10 @@ int VRT_switch_config(const char *); char *VRT_GetHdr(struct sess *, const char *); char *VRT_GetReq(struct sess *); +void VRT_handling(struct sess *sp, enum handling hand); -#define VRT_done(sess, hand) \ +#define VRT_done(sp, hand) \ do { \ - sess->handling = hand; \ - sess->done = 1; \ - return; \ + VRT_handling(sp, hand); \ + return (1); \ } while (0) diff --git a/varnish-cache/lib/libvcl/vcl_compile.c b/varnish-cache/lib/libvcl/vcl_compile.c index f3b63d24..ae7f3b97 100644 --- a/varnish-cache/lib/libvcl/vcl_compile.c +++ b/varnish-cache/lib/libvcl/vcl_compile.c @@ -962,12 +962,11 @@ Action(struct tokenlist *tl) case T_CALL: ExpectErr(tl, ID); AddRef(tl, tl->t, R_FUNC); - I(tl); - sbuf_printf(tl->fc, "VGC_function_%*.*s(sp);\n", + I(tl); sbuf_printf(tl->fc, + "if (VGC_function_%*.*s(sp))\n", tl->t->e - tl->t->b, tl->t->e - tl->t->b, tl->t->b); - I(tl); sbuf_printf(tl->fc, "if (sp->done)\n"); - I(tl); sbuf_printf(tl->fc, "\treturn;\n"); + I(tl); sbuf_printf(tl->fc, "\treturn (1);\n"); NextToken(tl); return; case T_REWRITE: @@ -1291,13 +1290,11 @@ Function(struct tokenlist *tl) NextToken(tl); ExpectErr(tl, ID); AddDef(tl, tl->t, R_FUNC); - sbuf_printf(tl->fh, "static void VGC_function_%*.*s (struct sess *sp);\n", + sbuf_printf(tl->fh, "static int VGC_function_%*.*s (struct sess *sp);\n", tl->t->e - tl->t->b, tl->t->e - tl->t->b, tl->t->b); - I(tl); - sbuf_printf(tl->fc, "static void\n"); - I(tl); - sbuf_printf(tl->fc, "VGC_function_%*.*s (struct sess *sp)\n", + I(tl); sbuf_printf(tl->fc, "static int\n"); + I(tl); sbuf_printf(tl->fc, "VGC_function_%*.*s (struct sess *sp)\n", tl->t->e - tl->t->b, tl->t->e - tl->t->b, tl->t->b); NextToken(tl); diff --git a/varnish-cache/lib/libvcl/vcl_fixed_token.c b/varnish-cache/lib/libvcl/vcl_fixed_token.c index 013d3800..14688b56 100644 --- a/varnish-cache/lib/libvcl/vcl_fixed_token.c +++ b/varnish-cache/lib/libvcl/vcl_fixed_token.c @@ -446,8 +446,6 @@ vcl_output_lang_h(FILE *f) fputs("\n", f); fputs(" enum handling handling;\n", f); fputs("\n", f); - fputs(" char done;\n", f); - fputs("\n", f); fputs(" TAILQ_ENTRY(sess) list;\n", f); fputs("\n", f); fputs(" sesscb_f *sesscb;\n", f); @@ -481,7 +479,7 @@ vcl_output_lang_h(FILE *f) fputs("#endif\n", f); fputs("\n", f); fputs("typedef void vcl_init_f(void);\n", f); - fputs("typedef void vcl_func_f(struct sess *sp);\n", f); + fputs("typedef int vcl_func_f(struct sess *sp);\n", f); fputs("\n", f); fputs("struct VCL_conf {\n", f); fputs(" unsigned magic;\n", f); @@ -529,11 +527,11 @@ vcl_output_lang_h(FILE *f) fputs("\n", f); fputs("char *VRT_GetHdr(struct sess *, const char *);\n", f); fputs("char *VRT_GetReq(struct sess *);\n", f); + fputs("void VRT_handling(struct sess *sp, enum handling hand);\n", f); fputs("\n", f); - fputs("#define VRT_done(sess, hand) \\\n", f); + fputs("#define VRT_done(sp, hand) \\\n", f); fputs(" do { \\\n", f); - fputs(" sess->handling = hand; \\\n", f); - fputs(" sess->done = 1; \\\n", f); - fputs(" return; \\\n", f); + fputs(" VRT_handling(sp, hand); \\\n", f); + fputs(" return (1); \\\n", f); fputs(" } while (0)\n", f); } -- 2.39.5