From: phk Date: Mon, 31 Jul 2006 20:27:02 +0000 (+0000) Subject: Log the headers we store in the object under ObjHeader so that X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=906b8627cb8a66d7f7d3f46ac1fa283d015f2fda;p=varnish Log the headers we store in the object under ObjHeader so that we don't get two confusing batches of TxHeader in the sessions logentries. git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@575 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- diff --git a/varnish-cache/bin/varnishd/cache.h b/varnish-cache/bin/varnishd/cache.h index 97c7658a..f6e04a09 100644 --- a/varnish-cache/bin/varnishd/cache.h +++ b/varnish-cache/bin/varnishd/cache.h @@ -66,7 +66,8 @@ struct http { char *f; /* first (F)ree byte */ char *e; /* (E)nd of buffer */ - unsigned conds; /* If-* headers present */ + unsigned char conds; /* If-* headers present */ + unsigned char objlog; struct http_hdr hd[MAX_HTTP_HDRS]; unsigned nhd; diff --git a/varnish-cache/bin/varnishd/cache_fetch.c b/varnish-cache/bin/varnishd/cache_fetch.c index 94064583..ead22c10 100644 --- a/varnish-cache/bin/varnishd/cache_fetch.c +++ b/varnish-cache/bin/varnishd/cache_fetch.c @@ -222,8 +222,15 @@ FetchBody(struct sess *sp) if (http_GetHdr(vc->http, H_Last_Modified, &b)) sp->obj->last_modified = TIM_parse(b); + /* + * We borrow the sessions workspace and http header for building the + * headers to store in the object, then copy them over there. + * The actual headers to reply with are built later on over in + * cache_response.c + */ sp->http->f = sp->http->v; sp->http->nhd = HTTP_HDR_FIRST; + sp->http->objlog = 1; /* log as SLT_ObjHeader */ http_CopyResp(sp->fd, sp->http, vc->http); http_FilterHeader(sp->fd, sp->http, vc->http, HTTPH_A_INS); @@ -234,10 +241,13 @@ FetchBody(struct sess *sp) cls = fetch_chunked(sp, vc->fd, vc->http); else cls = fetch_eof(sp, vc->fd, vc->http); - http_PrintfHeader(sp->fd, sp->http, "Content-Length: %u", sp->obj->len); + http_PrintfHeader(sp->fd, sp->http, + "Content-Length: %u", sp->obj->len); } else cls = 0; + sp->http->objlog = 0; http_CopyHttp(&sp->obj->http, sp->http); + sp->http->f = sp->http->v; if (http_GetHdr(vc->http, H_Connection, &b) && !strcasecmp(b, "close")) cls = 1; diff --git a/varnish-cache/bin/varnishd/cache_http.c b/varnish-cache/bin/varnishd/cache_http.c index c9240f70..012425c1 100644 --- a/varnish-cache/bin/varnishd/cache_http.c +++ b/varnish-cache/bin/varnishd/cache_http.c @@ -22,6 +22,9 @@ #define VSLH(ax, bx, cx, dx) \ VSLR((ax), (bx), (cx)->hd[(dx)].b, (cx)->hd[(dx)].e); +#define VSLHT(bx, cx, dx) \ + VSLH((cx)->objlog ? SLT_ObjHeader : SLT_TxHeader, bx, cx, dx) + /*--------------------------------------------------------------------*/ void @@ -588,7 +591,7 @@ http_copyheader(int fd, struct http *to, struct http *fm, unsigned n) if (to->nhd < MAX_HTTP_HDRS) { to->hd[to->nhd].b = fm->hd[n].b; to->hd[to->nhd].e = fm->hd[n].e; - VSLH(SLT_TxHeader, fd, to, to->nhd); + VSLHT(fd, to, to->nhd); to->nhd++; } else { VSL_stats->losthdr++; @@ -624,7 +627,7 @@ http_SetHeader(int fd, struct http *to, unsigned n, const char *hdr) n = to->nhd++; to->hd[n].b = (void*)(uintptr_t)hdr; to->hd[n].e = strchr(hdr, '\0'); - VSLH(SLT_TxHeader, fd, to, n); + VSLHT(fd, to, n); } /*--------------------------------------------------------------------*/ @@ -646,7 +649,7 @@ http_PrintfHeader(int fd, struct http *to, const char *fmt, ...) to->hd[to->nhd].b = to->f; to->hd[to->nhd].e = to->f + n; to->f += n + 1; - VSLH(SLT_TxHeader, fd, to, to->nhd); + VSLHT(fd, to, to->nhd); to->nhd++; } va_end(ap); diff --git a/varnish-cache/include/shmlog_tags.h b/varnish-cache/include/shmlog_tags.h index a77ac2de..2a0f8341 100644 --- a/varnish-cache/include/shmlog_tags.h +++ b/varnish-cache/include/shmlog_tags.h @@ -32,6 +32,7 @@ SLTM(URL) SLTM(Protocol) SLTM(RxHeader) SLTM(TxHeader) +SLTM(ObjHeader) SLTM(LostHeader) SLTM(TTL) SLTM(VCL_acl)