From c9af91e29623672a957a24312b6d79580207db15 Mon Sep 17 00:00:00 2001 From: phk Date: Sat, 24 Jun 2006 19:41:55 +0000 Subject: [PATCH] Add more shmemlog tags: one for each VCL method to record the return one for errors one for linking a client session to a backend connection Use them sensibly. Put VCL name of backend into struct backend to improve log messages git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@223 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- varnish-cache/bin/varnishd/cache.h | 1 + varnish-cache/bin/varnishd/cache_fetch.c | 2 +- varnish-cache/bin/varnishd/cache_pool.c | 4 ---- varnish-cache/bin/varnishd/cache_vcl.c | 9 +++------ varnish-cache/bin/varnishd/cache_vrt.c | 6 ++++++ varnish-cache/include/shmlog_tags.h | 8 +++++++- varnish-cache/include/vrt.h | 1 + varnish-cache/lib/libvcl/vcl_compile.c | 7 ++++++- varnish-cache/lib/libvcl/vcl_fixed_token.c | 1 + 9 files changed, 26 insertions(+), 13 deletions(-) diff --git a/varnish-cache/bin/varnishd/cache.h b/varnish-cache/bin/varnishd/cache.h index 7325a63f..86eb682f 100644 --- a/varnish-cache/bin/varnishd/cache.h +++ b/varnish-cache/bin/varnishd/cache.h @@ -104,6 +104,7 @@ struct sess { }; struct backend { + const char *vcl_name; const char *hostname; const char *portname; unsigned ip; diff --git a/varnish-cache/bin/varnishd/cache_fetch.c b/varnish-cache/bin/varnishd/cache_fetch.c index 34e82001..ed1518f1 100644 --- a/varnish-cache/bin/varnishd/cache_fetch.c +++ b/varnish-cache/bin/varnishd/cache_fetch.c @@ -204,7 +204,7 @@ FetchSession(struct worker *w, struct sess *sp) fd = VBE_GetFd(sp->backend, &fd_token); assert(fd != -1); - VSL(SLT_Handling, sp->fd, "Fetch fd %d", fd); + VSL(SLT_Backend, sp->fd, "%d %s", fd, sp->backend->vcl_name); hp = http_New(); http_BuildSbuf(1, w->sb, sp->http); diff --git a/varnish-cache/bin/varnishd/cache_pool.c b/varnish-cache/bin/varnishd/cache_pool.c index 4810b077..cb74cc5d 100644 --- a/varnish-cache/bin/varnishd/cache_pool.c +++ b/varnish-cache/bin/varnishd/cache_pool.c @@ -110,23 +110,19 @@ CacheWorker(void *priv) for (done = 0; !done; ) { switch(sp->handling) { case VCL_RET_LOOKUP: - VSL(SLT_Handling, sp->fd, "Lookup"); done = LookupSession(&w, sp); break; case VCL_RET_FETCH: done = FetchSession(&w, sp); break; case VCL_RET_DELIVER: - VSL(SLT_Handling, sp->fd, "Deliver"); done = DeliverSession(&w, sp); break; case VCL_RET_PIPE: - VSL(SLT_Handling, sp->fd, "Pipe"); PipeSession(&w, sp); done = 1; break; case VCL_RET_PASS: - VSL(SLT_Handling, sp->fd, "Pass"); PassSession(&w, sp); done = 1; break; diff --git a/varnish-cache/bin/varnishd/cache_vcl.c b/varnish-cache/bin/varnishd/cache_vcl.c index 2c70da21..3dc49426 100644 --- a/varnish-cache/bin/varnishd/cache_vcl.c +++ b/varnish-cache/bin/varnishd/cache_vcl.c @@ -212,15 +212,11 @@ CheckHandling(struct sess *sp, const char *func, unsigned bitmap) u = sp->handling; n = HandlingName(u); - if (n != NULL) - VSL(SLT_Handling, sp->fd, "%s(): %s", func, n); - else - VSL(SLT_Handling, sp->fd, "%s(): Illegal: 0x%x", func, u); if (u & (u - 1)) - VSL(SLT_Debug, sp->fd, + VSL(SLT_Error, sp->fd, "Illegal handling after %s function: 0x%x", func, u); else if (!(u & bitmap)) - VSL(SLT_Debug, sp->fd, + VSL(SLT_Error, sp->fd, "Wrong handling after %s function: 0x%x", func, u); else return; @@ -235,6 +231,7 @@ VCL_##func##_method(struct sess *sp) \ sp->handling = 0; \ sp->vcl->func##_func(sp); \ CheckHandling(sp, #func, (bitmap)); \ + VSL(SLT_vcl_##func, sp->fd, "%s", HandlingName(sp->handling)); \ } #define VCL_RET_MAC(l,u,b) diff --git a/varnish-cache/bin/varnishd/cache_vrt.c b/varnish-cache/bin/varnishd/cache_vrt.c index 1030f331..0cb02c3d 100644 --- a/varnish-cache/bin/varnishd/cache_vrt.c +++ b/varnish-cache/bin/varnishd/cache_vrt.c @@ -102,6 +102,12 @@ VRT_set_backend_portname(struct backend *be, const char *p) be->portname = p; } +void +VRT_set_backend_name(struct backend *be, const char *p) +{ + be->vcl_name = p; +} + void VRT_alloc_backends(struct VCL_conf *cp) { diff --git a/varnish-cache/include/shmlog_tags.h b/varnish-cache/include/shmlog_tags.h index 9a0b33cc..2a28ffe8 100644 --- a/varnish-cache/include/shmlog_tags.h +++ b/varnish-cache/include/shmlog_tags.h @@ -7,6 +7,7 @@ */ SLTM(Debug) +SLTM(Error) SLTM(CLI) SLTM(SessionOpen) SLTM(SessionReuse) @@ -16,7 +17,12 @@ SLTM(BackendReuse) SLTM(BackendClose) SLTM(HttpError) SLTM(ClientAddr) -SLTM(Handling) +#define VCL_RET_MAC(l,u,b) +#define VCL_MET_MAC(l,u,b) SLTM(vcl_##l) +#include "vcl_returns.h" +#undef VCL_MET_MAC +#undef VCL_RET_MAC +SLTM(Backend) SLTM(Request) SLTM(Response) SLTM(Status) diff --git a/varnish-cache/include/vrt.h b/varnish-cache/include/vrt.h index 3779a6a4..62b291e4 100644 --- a/varnish-cache/include/vrt.h +++ b/varnish-cache/include/vrt.h @@ -40,6 +40,7 @@ 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 *); diff --git a/varnish-cache/lib/libvcl/vcl_compile.c b/varnish-cache/lib/libvcl/vcl_compile.c index 0d359b54..5c9a308d 100644 --- a/varnish-cache/lib/libvcl/vcl_compile.c +++ b/varnish-cache/lib/libvcl/vcl_compile.c @@ -42,8 +42,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -1241,6 +1241,11 @@ Backend(struct tokenlist *tl) tl->t->e - tl->t->b, tl->t->e - tl->t->b, tl->t->b); I(tl); sbuf_printf(tl->fc, "\tconst char *p;\n"); + I(tl); sbuf_printf(tl->fc, "\n"); + I(tl); sbuf_printf(tl->fc, + "\tVRT_set_backend_name(backend, \"%*.*s\");\n", + tl->t->e - tl->t->b, + tl->t->e - tl->t->b, tl->t->b); NextToken(tl); ExpectErr(tl, '{'); NextToken(tl); diff --git a/varnish-cache/lib/libvcl/vcl_fixed_token.c b/varnish-cache/lib/libvcl/vcl_fixed_token.c index 947e9276..f10b5cea 100644 --- a/varnish-cache/lib/libvcl/vcl_fixed_token.c +++ b/varnish-cache/lib/libvcl/vcl_fixed_token.c @@ -485,6 +485,7 @@ vcl_output_lang_h(FILE *f) fputs("int VRT_obj_valid(struct sess *);\n", f); fputs("int VRT_obj_cacheable(struct sess *);\n", f); fputs("\n", f); + fputs("void VRT_set_backend_name(struct backend *, const char *);\n", f); fputs("void VRT_set_backend_hostname(struct backend *, const char *);\n", f); fputs("void VRT_set_backend_portname(struct backend *, const char *);\n", f); fputs("\n", f); -- 2.39.5