[master] f177a35 Rework the way we log HTTP headers: Rather than the Rx/Tx/Obj, tag them with Req/Resp/Bereq/Beresp/Obj instead.

Poul-Henning Kamp phk at varnish-cache.org
Thu Mar 22 18:53:04 CET 2012


commit f177a357f792e116f9cc3ba4c64dfc5df3735ae5
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Thu Mar 22 14:33:34 2012 +0000

    Rework the way we log HTTP headers:  Rather than the Rx/Tx/Obj, tag them
    with Req/Resp/Bereq/Beresp/Obj instead.

diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index ec385c5..0bb75df 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -151,9 +151,11 @@ struct ws {
  */
 
 enum httpwhence {
-	HTTP_Rx	 = 1,
-	HTTP_Tx  = 2,
-	HTTP_Obj = 3
+	HTTP_Req	= 1,
+	HTTP_Resp,
+	HTTP_Bereq,
+	HTTP_Beresp,
+	HTTP_Obj
 };
 
 /* NB: remember to update http_Copy() if you add fields */
@@ -810,7 +812,7 @@ void http_PrintfHeader(struct http *to, const char *fmt, ...)
 void http_SetHeader(struct http *to, const char *hdr);
 void http_SetH(const struct http *to, unsigned n, const char *fm);
 void http_ForceGet(const struct http *to);
-void http_Setup(struct http *ht, struct ws *ws, struct vsl_log *);
+void HTTP_Setup(struct http *, struct ws *, struct vsl_log *, enum httpwhence);
 void http_Teardown(struct http *ht);
 int http_GetHdr(const struct http *hp, const char *hdr, char **ptr);
 int http_GetHdrData(const struct http *hp, const char *hdr,
diff --git a/bin/varnishd/cache/cache_center.c b/bin/varnishd/cache/cache_center.c
index 6b692f8..7104e0f 100644
--- a/bin/varnishd/cache/cache_center.c
+++ b/bin/varnishd/cache/cache_center.c
@@ -275,7 +275,7 @@ cnt_prepresp(struct sess *sp, struct worker *wrk, struct req *req)
 			req->obj->last_lru = req->t_resp;
 		req->obj->last_use = req->t_resp;	/* XXX: locking ? */
 	}
-	http_Setup(req->resp, req->ws, req->vsl);
+	HTTP_Setup(req->resp, req->ws, req->vsl, HTTP_Resp);
 	RES_BuildHttp(sp);
 	VCL_deliver_method(sp);
 	switch (req->handling) {
@@ -577,7 +577,7 @@ cnt_fetch(struct sess *sp, struct worker *wrk, struct req *req)
 	AZ(bo->should_close);
 	AZ(req->storage_hint);
 
-	http_Setup(bo->beresp, bo->ws, bo->vsl);
+	HTTP_Setup(bo->beresp, bo->ws, bo->vsl, HTTP_Beresp);
 
 	need_host_hdr = !http_GetHdr(bo->bereq, H_Host, NULL);
 
@@ -1197,7 +1197,7 @@ cnt_miss(struct sess *sp, struct worker *wrk, struct req *req)
 	CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
 	AZ(req->obj);
 
-	http_Setup(bo->bereq, bo->ws, bo->vsl);
+	HTTP_Setup(bo->bereq, bo->ws, bo->vsl, HTTP_Bereq);
 	http_FilterReq(sp, HTTPH_R_FETCH);
 	http_ForceGet(bo->bereq);
 	if (cache_param->http_gzip_support) {
@@ -1275,7 +1275,7 @@ cnt_pass(struct sess *sp, struct worker *wrk, struct req *req)
 	bo = req->busyobj;
 	bo->vsl->wid = sp->vsl_id;
 	bo->refcount = 2;
-	http_Setup(bo->bereq, bo->ws, bo->vsl);
+	HTTP_Setup(bo->bereq, bo->ws, bo->vsl, HTTP_Bereq);
 	http_FilterReq(sp, HTTPH_R_PASS);
 
 	VCL_pass_method(sp);
@@ -1332,7 +1332,7 @@ cnt_pipe(struct sess *sp, struct worker *wrk, struct req *req)
 	req->busyobj = VBO_GetBusyObj(wrk);
 	bo = req->busyobj;
 	bo->vsl->wid = sp->vsl_id;
-	http_Setup(bo->bereq, bo->ws, bo->vsl);
+	HTTP_Setup(bo->bereq, bo->ws, bo->vsl, HTTP_Bereq);
 	http_FilterReq(sp, 0);
 
 	VCL_pipe_method(sp);
@@ -1508,7 +1508,7 @@ cnt_start(struct sess *sp, struct worker *wrk, struct req *req)
 
 	EXP_Clr(&req->exp);
 
-	http_Setup(req->http, req->ws, req->vsl);
+	HTTP_Setup(req->http, req->ws, req->vsl, HTTP_Req);
 	req->err_code = http_DissectRequest(sp);
 
 	/* If we could not even parse the request, just close */
diff --git a/bin/varnishd/cache/cache_http.c b/bin/varnishd/cache/cache_http.c
index bcde416..0380469 100644
--- a/bin/varnishd/cache/cache_http.c
+++ b/bin/varnishd/cache/cache_http.c
@@ -42,9 +42,11 @@
 #undef HTTPH
 
 static const enum VSL_tag_e foo[] = {
-	[HTTP_Rx] = SLT_RxRequest,
-	[HTTP_Tx] = SLT_TxRequest,
-	[HTTP_Obj] = SLT_ObjRequest,
+	[HTTP_Req]	= SLT_ReqRequest,
+	[HTTP_Resp]	= SLT_RespRequest,
+	[HTTP_Bereq]	= SLT_BereqRequest,
+	[HTTP_Beresp]	= SLT_BerespRequest,
+	[HTTP_Obj]	= SLT_ObjRequest,
 };
 
 static enum VSL_tag_e
@@ -54,7 +56,7 @@ http2shmlog(const struct http *hp, int t)
 	CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC);
 	if (t > HTTP_HDR_FIRST)
 		t = HTTP_HDR_FIRST;
-	assert(hp->logtag >= HTTP_Rx && hp->logtag <= HTTP_Obj); /*lint !e685*/
+	assert(hp->logtag >= HTTP_Req && hp->logtag <= HTTP_Obj); /*lint !e685*/
 	assert(t >= HTTP_HDR_REQ && t <= HTTP_HDR_FIRST);
 	return ((enum VSL_tag_e)(foo[hp->logtag] + t));
 }
@@ -118,9 +120,11 @@ HTTP_create(void *p, uint16_t nhttp)
 /*--------------------------------------------------------------------*/
 
 void
-http_Setup(struct http *hp, struct ws *ws, struct vsl_log *vsl)
+HTTP_Setup(struct http *hp, struct ws *ws, struct vsl_log *vsl,
+    enum httpwhence  whence)
 {
 	http_Teardown(hp);
+	hp->logtag = whence;
 	hp->ws = ws;
 	hp->vsl = vsl;
 }
@@ -659,8 +663,6 @@ http_DissectRequest(const struct sess *sp)
 	hp = sp->req->http;
 	CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC);
 
-	hp->logtag = HTTP_Rx;
-
 	retval = http_splitline(hp, htc,
 	    HTTP_HDR_REQ, HTTP_HDR_URL, HTTP_HDR_PROTO);
 	if (retval != 0) {
@@ -683,7 +685,6 @@ http_DissectResponse(struct http *hp, const struct http_conn *htc)
 
 	CHECK_OBJ_NOTNULL(htc, HTTP_CONN_MAGIC);
 	CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC);
-	hp->logtag = HTTP_Rx;
 
 	if (http_splitline(hp, htc,
 	    HTTP_HDR_PROTO, HTTP_HDR_STATUS, HTTP_HDR_RESPONSE))
@@ -843,7 +844,6 @@ http_FilterReq(const struct sess *sp, unsigned how)
 
 	hp = sp->req->busyobj->bereq;
 	CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC);
-	hp->logtag = HTTP_Tx;
 
 	http_linkh(hp, sp->req->http, HTTP_HDR_REQ);
 	http_linkh(hp, sp->req->http, HTTP_HDR_URL);
diff --git a/bin/varnishd/cache/cache_response.c b/bin/varnishd/cache/cache_response.c
index 1e065ba..8579e37 100644
--- a/bin/varnishd/cache/cache_response.c
+++ b/bin/varnishd/cache/cache_response.c
@@ -115,7 +115,6 @@ RES_BuildHttp(const struct sess *sp)
 	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
 
 	http_ClrHeader(req->resp);
-	req->resp->logtag = HTTP_Tx;
 	http_FilterResp(req->obj->http, req->resp, 0);
 
 	if (!(req->res_mode & RES_LEN)) {
diff --git a/bin/varnishd/storage/stevedore.c b/bin/varnishd/storage/stevedore.c
index 9f013d2..b71401d 100644
--- a/bin/varnishd/storage/stevedore.c
+++ b/bin/varnishd/storage/stevedore.c
@@ -256,7 +256,7 @@ STV_MkObject(struct stevedore *stv, struct busyobj *bo, struct objcore **ocp,
 	WS_Assert(o->ws_o);
 	assert(o->ws_o->e <= (char*)ptr + ltot);
 
-	http_Setup(o->http, o->ws_o, bo->vsl);
+	HTTP_Setup(o->http, o->ws_o, bo->vsl, HTTP_Obj);
 	o->http->magic = HTTP_MAGIC;
 	o->exp = bo->exp;
 	VTAILQ_INIT(&o->store);
diff --git a/include/tbl/vsl_tags.h b/include/tbl/vsl_tags.h
index ecf0a20..1321493 100644
--- a/include/tbl/vsl_tags.h
+++ b/include/tbl/vsl_tags.h
@@ -53,11 +53,19 @@ SLTM(Length)
 
 SLTM(FetchError)
 
-#define SLTH(aa, bb)	SLTM(Rx##aa)
+#define SLTH(aa, bb)	SLTM(Req##aa)
 #include "tbl/vsl_tags_http.h"
 #undef SLTH
 
-#define SLTH(aa, bb)	SLTM(Tx##aa)
+#define SLTH(aa, bb)	SLTM(Resp##aa)
+#include "tbl/vsl_tags_http.h"
+#undef SLTH
+
+#define SLTH(aa, bb)	SLTM(Bereq##aa)
+#include "tbl/vsl_tags_http.h"
+#undef SLTH
+
+#define SLTH(aa, bb)	SLTM(Beresp##aa)
 #include "tbl/vsl_tags_http.h"
 #undef SLTH
 



More information about the varnish-commit mailing list