[experimental-ims] f7dbf53 Clean up a lot of now needless argument passing for struct http's VSL logging. More to come.
Geoff Simmons
geoff at varnish-cache.org
Tue Feb 14 17:49:35 CET 2012
commit f7dbf53eb01d26170f6c4bafd3f0a50d00444dc5
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Tue Feb 14 10:03:55 2012 +0000
Clean up a lot of now needless argument passing for struct http's
VSL logging. More to come.
diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 98771a3..0bac299 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -799,13 +799,11 @@ const char *http_StatusMessage(unsigned);
unsigned http_EstimateWS(const struct http *fm, unsigned how, uint16_t *nhd);
void HTTP_Init(void);
void http_ClrHeader(struct http *to);
-unsigned http_Write(struct worker *w, unsigned vsl_id, const struct http *hp,
- int resp);
+unsigned http_Write(struct worker *w, const struct http *hp, int resp);
void http_SetResp(struct http *to, const char *proto, uint16_t status,
const char *response);
void http_FilterReq(const struct sess *sp, unsigned how);
-void http_FilterResp(const struct sess *sp, const struct http *fm, struct http *to,
- unsigned how);
+void http_FilterResp(const struct http *fm, struct http *to, unsigned how);
void http_PutProtocol(struct worker *w, unsigned vsl_id, const struct http *to,
const char *protocol);
void http_PutStatus(struct http *to, uint16_t status);
@@ -830,8 +828,7 @@ uint16_t http_GetStatus(const struct http *hp);
const char *http_GetReq(const struct http *hp);
int http_HdrIs(const struct http *hp, const char *hdr, const char *val);
uint16_t http_DissectRequest(const struct sess *sp);
-uint16_t http_DissectResponse(struct worker *w, const struct http_conn *htc,
- struct http *sp);
+uint16_t http_DissectResponse(struct http *sp, const struct http_conn *htc);
const char *http_DoConnection(const struct http *hp);
void http_CopyHome(struct worker *w, unsigned vsl_id, const struct http *hp);
void http_Unset(struct http *hp, const char *hdr);
diff --git a/bin/varnishd/cache/cache_center.c b/bin/varnishd/cache/cache_center.c
index f7cbc38..54a883b 100644
--- a/bin/varnishd/cache/cache_center.c
+++ b/bin/varnishd/cache/cache_center.c
@@ -838,7 +838,7 @@ cnt_prepfetch(struct sess *sp, struct worker *wrk, struct req *req)
hp2 = req->obj->http;
hp2->logtag = HTTP_Obj;
- http_FilterResp(sp, hp, hp2, pass ? HTTPH_R_PASS : HTTPH_A_INS);
+ http_FilterResp(hp, hp2, pass ? HTTPH_R_PASS : HTTPH_A_INS);
http_CopyHome(wrk, sp->vsl_id, hp2);
if (http_GetHdr(hp, H_Last_Modified, &b))
diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index 1e2ef44..327ae0a 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -427,7 +427,7 @@ FetchHdr(struct sess *sp, int need_host_hdr, int sendbody)
(void)VTCP_blocking(vc->fd); /* XXX: we should timeout instead */
WRW_Reserve(wrk, &vc->fd);
- (void)http_Write(wrk, vc->vsl_id, hp, 0); /* XXX: stats ? */
+ (void)http_Write(wrk, hp, 0); /* XXX: stats ? */
/* Deal with any message-body the request might have */
i = FetchReqBody(sp, sendbody);
@@ -480,7 +480,7 @@ FetchHdr(struct sess *sp, int need_host_hdr, int sendbody)
hp = wrk->busyobj->beresp;
- if (http_DissectResponse(wrk, htc, hp)) {
+ if (http_DissectResponse(hp, htc)) {
WSP(sp, SLT_FetchError, "http format error");
VDI_CloseFd(sp->wrk, &sp->wrk->busyobj->vbc);
/* XXX: other cleanup ? */
diff --git a/bin/varnishd/cache/cache_http.c b/bin/varnishd/cache/cache_http.c
index c8db4c7..2a97829 100644
--- a/bin/varnishd/cache/cache_http.c
+++ b/bin/varnishd/cache/cache_http.c
@@ -73,11 +73,12 @@ http2shmlog(const struct http *hp, int t)
}
static void
-WSLH(struct worker *w, unsigned vsl_id, const struct http *hp, unsigned hdr)
+http_VSLH(const struct http *hp, unsigned hdr)
{
- AN(vsl_id & (VSL_CLIENTMARKER|VSL_BACKENDMARKER));
- WSLR(w->vsl, http2shmlog(hp, hdr), vsl_id, hp->hd[hdr]);
+ AN(hp->vsl);
+ AN(hp->vsl->wid & (VSL_CLIENTMARKER|VSL_BACKENDMARKER));
+ WSLR(hp->vsl, http2shmlog(hp, hdr), -1, hp->hd[hdr]);
}
/*--------------------------------------------------------------------*/
@@ -491,8 +492,7 @@ http_GetReq(const struct http *hp)
*/
static uint16_t
-http_dissect_hdrs(struct worker *w, struct http *hp, unsigned vsl_id, char *p,
- const struct http_conn *htc)
+http_dissect_hdrs(struct http *hp, char *p, const struct http_conn *htc)
{
char *q, *r;
txt t = htc->rxbuf;
@@ -528,7 +528,7 @@ http_dissect_hdrs(struct worker *w, struct http *hp, unsigned vsl_id, char *p,
if (q - p > htc->maxhdr) {
VSC_C_main->losthdr++;
- WSL(w->vsl, SLT_LostHeader, vsl_id, "%.*s",
+ WSL(hp->vsl, SLT_LostHeader, -1, "%.*s",
(int)(q - p > 20 ? 20 : q - p), p);
return (413);
}
@@ -550,11 +550,11 @@ http_dissect_hdrs(struct worker *w, struct http *hp, unsigned vsl_id, char *p,
hp->hdf[hp->nhd] = 0;
hp->hd[hp->nhd].b = p;
hp->hd[hp->nhd].e = q;
- WSLH(w, vsl_id, hp, hp->nhd);
+ http_VSLH(hp, hp->nhd);
hp->nhd++;
} else {
VSC_C_main->losthdr++;
- WSL(w->vsl, SLT_LostHeader, vsl_id, "%.*s",
+ WSL(hp->vsl, SLT_LostHeader, -1, "%.*s",
(int)(q - p > 20 ? 20 : q - p), p);
return (413);
}
@@ -567,7 +567,7 @@ http_dissect_hdrs(struct worker *w, struct http *hp, unsigned vsl_id, char *p,
*/
static uint16_t
-http_splitline(struct worker *w, unsigned vsl_id, struct http *hp,
+http_splitline(struct http *hp,
const struct http_conn *htc, int h1, int h2, int h3)
{
char *p, *q;
@@ -629,17 +629,17 @@ http_splitline(struct worker *w, unsigned vsl_id, struct http *hp,
p += vct_skipcrlf(p);
*hp->hd[h1].e = '\0';
- WSLH(w, vsl_id, hp, h1);
+ http_VSLH(hp, h1);
*hp->hd[h2].e = '\0';
- WSLH(w, vsl_id, hp, h2);
+ http_VSLH(hp, h2);
if (hp->hd[h3].e != NULL) {
*hp->hd[h3].e = '\0';
- WSLH(w, vsl_id, hp, h3);
+ http_VSLH(hp, h3);
}
- return (http_dissect_hdrs(w, hp, vsl_id, p, htc));
+ return (http_dissect_hdrs(hp, p, htc));
}
/*--------------------------------------------------------------------*/
@@ -674,7 +674,7 @@ http_DissectRequest(const struct sess *sp)
hp->logtag = HTTP_Rx;
- retval = http_splitline(sp->wrk, sp->vsl_id, hp, htc,
+ retval = http_splitline(hp, htc,
HTTP_HDR_REQ, HTTP_HDR_URL, HTTP_HDR_PROTO);
if (retval != 0) {
WSPR(sp, SLT_HttpGarbage, htc->rxbuf);
@@ -687,8 +687,7 @@ http_DissectRequest(const struct sess *sp)
/*--------------------------------------------------------------------*/
uint16_t
-http_DissectResponse(struct worker *w, const struct http_conn *htc,
- struct http *hp)
+http_DissectResponse(struct http *hp, const struct http_conn *htc)
{
int j;
uint16_t retval = 0;
@@ -699,7 +698,7 @@ http_DissectResponse(struct worker *w, const struct http_conn *htc,
CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC);
hp->logtag = HTTP_Rx;
- if (http_splitline(w, htc->vsl_id, hp, htc,
+ if (http_splitline(hp, htc,
HTTP_HDR_PROTO, HTTP_HDR_STATUS, HTTP_HDR_RESPONSE))
retval = 503;
@@ -725,7 +724,7 @@ http_DissectResponse(struct worker *w, const struct http_conn *htc,
}
if (retval != 0) {
- WSLR(w->vsl, SLT_HttpGarbage, htc->vsl_id, htc->rxbuf);
+ WSLR(hp->vsl, SLT_HttpGarbage, -1, htc->rxbuf);
assert(retval >= 100 && retval <= 999);
hp->status = retval;
} else {
@@ -818,8 +817,7 @@ http_EstimateWS(const struct http *fm, unsigned how, uint16_t *nhd)
/*--------------------------------------------------------------------*/
static void
-http_filterfields(struct worker *w, unsigned vsl_id, struct http *to,
- const struct http *fm, unsigned how)
+http_filterfields(struct http *to, const struct http *fm, unsigned how)
{
unsigned u;
@@ -844,7 +842,7 @@ http_filterfields(struct worker *w, unsigned vsl_id, struct http *to,
to->nhd++;
} else {
VSC_C_main->losthdr++;
- WSLR(w->vsl, SLT_LostHeader, vsl_id, fm->hd[u]);
+ WSLR(to->vsl, SLT_LostHeader, -1, fm->hd[u]);
}
}
}
@@ -866,7 +864,7 @@ http_FilterReq(const struct sess *sp, unsigned how)
http_SetH(hp, HTTP_HDR_PROTO, "HTTP/1.1");
else
http_linkh(hp, sp->req->http, HTTP_HDR_PROTO);
- http_filterfields(sp->wrk, sp->vsl_id, hp, sp->req->http, how);
+ http_filterfields(hp, sp->req->http, how);
http_PrintfHeader(sp->wrk, sp->vsl_id, hp,
"X-Varnish: %u", sp->req->xid);
}
@@ -874,8 +872,7 @@ http_FilterReq(const struct sess *sp, unsigned how)
/*--------------------------------------------------------------------*/
void
-http_FilterResp(const struct sess *sp, const struct http *fm, struct http *to,
- unsigned how)
+http_FilterResp(const struct http *fm, struct http *to, unsigned how)
{
CHECK_OBJ_NOTNULL(fm, HTTP_MAGIC);
@@ -883,7 +880,7 @@ http_FilterResp(const struct sess *sp, const struct http *fm, struct http *to,
http_SetH(to, HTTP_HDR_PROTO, "HTTP/1.1");
to->status = fm->status;
http_linkh(to, fm, HTTP_HDR_RESPONSE);
- http_filterfields(sp->wrk, sp->vsl_id, to, fm, how);
+ http_filterfields(to, fm, how);
}
/*--------------------------------------------------------------------
@@ -901,13 +898,13 @@ http_CopyHome(struct worker *w, unsigned vsl_id, const struct http *hp)
if (hp->hd[u].b == NULL)
continue;
if (hp->hd[u].b >= hp->ws->s && hp->hd[u].e <= hp->ws->e) {
- WSLH(w, vsl_id, hp, u);
+ http_VSLH(hp, u);
continue;
}
l = Tlen(hp->hd[u]);
p = WS_Alloc(hp->ws, l + 1);
if (p != NULL) {
- WSLH(w, vsl_id, hp, u);
+ http_VSLH(hp, u);
memcpy(p, hp->hd[u].b, l + 1L);
hp->hd[u].b = p;
hp->hd[u].e = p + l;
@@ -1070,13 +1067,13 @@ HTTP_Copy(struct http *to, const struct http * const fm)
/*--------------------------------------------------------------------*/
unsigned
-http_Write(struct worker *w, unsigned vsl_id, const struct http *hp, int resp)
+http_Write(struct worker *w, const struct http *hp, int resp)
{
unsigned u, l;
if (resp) {
l = WRW_WriteH(w, &hp->hd[HTTP_HDR_PROTO], " ");
- WSLH(w, vsl_id, hp, HTTP_HDR_PROTO);
+ http_VSLH(hp, HTTP_HDR_PROTO);
hp->hd[HTTP_HDR_STATUS].b = WS_Alloc(hp->ws, 4);
AN(hp->hd[HTTP_HDR_STATUS].b);
@@ -1085,18 +1082,18 @@ http_Write(struct worker *w, unsigned vsl_id, const struct http *hp, int resp)
hp->hd[HTTP_HDR_STATUS].e = hp->hd[HTTP_HDR_STATUS].b + 3;
l += WRW_WriteH(w, &hp->hd[HTTP_HDR_STATUS], " ");
- WSLH(w, vsl_id, hp, HTTP_HDR_STATUS);
+ http_VSLH(hp, HTTP_HDR_STATUS);
l += WRW_WriteH(w, &hp->hd[HTTP_HDR_RESPONSE], "\r\n");
- WSLH(w, vsl_id, hp, HTTP_HDR_RESPONSE);
+ http_VSLH(hp, HTTP_HDR_RESPONSE);
} else {
AN(hp->hd[HTTP_HDR_URL].b);
l = WRW_WriteH(w, &hp->hd[HTTP_HDR_REQ], " ");
- WSLH(w, vsl_id, hp, HTTP_HDR_REQ);
+ http_VSLH(hp, HTTP_HDR_REQ);
l += WRW_WriteH(w, &hp->hd[HTTP_HDR_URL], " ");
- WSLH(w, vsl_id, hp, HTTP_HDR_URL);
+ http_VSLH(hp, HTTP_HDR_URL);
l += WRW_WriteH(w, &hp->hd[HTTP_HDR_PROTO], "\r\n");
- WSLH(w, vsl_id, hp, HTTP_HDR_PROTO);
+ http_VSLH(hp, HTTP_HDR_PROTO);
}
for (u = HTTP_HDR_FIRST; u < hp->nhd; u++) {
if (hp->hd[u].b == NULL)
@@ -1104,7 +1101,7 @@ http_Write(struct worker *w, unsigned vsl_id, const struct http *hp, int resp)
AN(hp->hd[u].b);
AN(hp->hd[u].e);
l += WRW_WriteH(w, &hp->hd[u], "\r\n");
- WSLH(w, vsl_id, hp, u);
+ http_VSLH(hp, u);
}
l += WRW_Write(w, "\r\n", -1);
return (l);
diff --git a/bin/varnishd/cache/cache_pipe.c b/bin/varnishd/cache/cache_pipe.c
index 21fefef..6f1fbcb 100644
--- a/bin/varnishd/cache/cache_pipe.c
+++ b/bin/varnishd/cache/cache_pipe.c
@@ -80,7 +80,7 @@ PipeSession(struct sess *sp)
WRW_Reserve(w, &vc->fd);
sp->wrk->acct_tmp.hdrbytes +=
- http_Write(w, sp->vsl_id, sp->wrk->busyobj->bereq, 0);
+ http_Write(w, sp->wrk->busyobj->bereq, 0);
if (sp->req->htc->pipeline.b != NULL)
sp->wrk->acct_tmp.bodybytes +=
diff --git a/bin/varnishd/cache/cache_response.c b/bin/varnishd/cache/cache_response.c
index 5e4cab6..df9c137 100644
--- a/bin/varnishd/cache/cache_response.c
+++ b/bin/varnishd/cache/cache_response.c
@@ -117,7 +117,7 @@ RES_BuildHttp(const struct sess *sp)
http_ClrHeader(req->resp);
req->resp->logtag = HTTP_Tx;
- http_FilterResp(sp, req->obj->http, req->resp, 0);
+ http_FilterResp(req->obj->http, req->resp, 0);
if (!(req->res_mode & RES_LEN)) {
http_Unset(req->resp, H_Content_Length);
@@ -278,7 +278,7 @@ RES_WriteObj(struct sess *sp)
*/
if (!(req->res_mode & RES_ESI_CHILD))
sp->wrk->acct_tmp.hdrbytes +=
- http_Write(sp->wrk, sp->vsl_id, req->resp, 1);
+ http_Write(sp->wrk, req->resp, 1);
if (!req->wantbody)
req->res_mode &= ~RES_CHUNKED;
@@ -341,7 +341,7 @@ RES_StreamStart(struct sess *sp)
"Content-Length: %s", sp->wrk->busyobj->h_content_length);
sp->wrk->acct_tmp.hdrbytes +=
- http_Write(sp->wrk, sp->vsl_id, sp->req->resp, 1);
+ http_Write(sp->wrk, sp->req->resp, 1);
if (req->res_mode & RES_CHUNKED)
WRW_Chunked(sp->wrk);
diff --git a/bin/varnishd/cache/cache_shmlog.c b/bin/varnishd/cache/cache_shmlog.c
index 299389f..d4dae9d 100644
--- a/bin/varnishd/cache/cache_shmlog.c
+++ b/bin/varnishd/cache/cache_shmlog.c
@@ -208,6 +208,8 @@ WSLR(struct vsl_log *vsl, enum VSL_tag_e tag, int id, txt t)
unsigned l, mlen;
Tcheck(t);
+ if (id == -1)
+ id = vsl->wid;
mlen = cache_param->shm_reclen;
/* Truncate */
@@ -279,6 +281,8 @@ WSL(struct vsl_log *vsl, enum VSL_tag_e tag, int id, const char *fmt, ...)
{
va_list ap;
+ if (id == -1)
+ id = vsl->wid;
AN(fmt);
va_start(ap, fmt);
wsl(vsl, tag, id, fmt, ap);
More information about the varnish-commit
mailing list