[experimental-ims] e9e3e2e Eliminate a lot of arguments to http_ functions which used to convey the VSL coords which are now a property of struct http.
Geoff Simmons
geoff at varnish-cache.org
Tue Feb 14 17:49:35 CET 2012
commit e9e3e2e80f0e1d6aad3899a55647ed2b5e311673
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Tue Feb 14 10:31:51 2012 +0000
Eliminate a lot of arguments to http_ functions which used to convey
the VSL coords which are now a property of struct http.
diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 0bac299..2349470 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -691,7 +691,7 @@ struct vbc *VDI_GetFd(const struct director *, struct sess *sp);
int VDI_Healthy(const struct director *, const struct sess *sp);
void VDI_CloseFd(struct worker *wrk, struct vbc **vbp);
void VDI_RecycleFd(struct worker *wrk, struct vbc **vbp);
-void VDI_AddHostHeader(struct worker *wrk, const struct vbc *vbc);
+void VDI_AddHostHeader(struct http *to, const struct vbc *vbc);
void VBE_Poll(void);
void VDI_Init(void);
@@ -804,16 +804,12 @@ 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 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_PutProtocol(const struct http *to, const char *protocol);
void http_PutStatus(struct http *to, uint16_t status);
-void http_PutResponse(struct worker *w, unsigned vsl_id, const struct http *to,
- const char *response);
-void http_PrintfHeader(struct worker *w, unsigned vsl_id, struct http *to,
- const char *fmt, ...)
- __printflike(4, 5);
-void http_SetHeader(struct worker *w, unsigned vsl_id, struct http *to,
- const char *hdr);
+void http_PutResponse(const struct http *to, const char *response);
+void http_PrintfHeader(struct http *to, const char *fmt, ...)
+ __printflike(2, 3);
+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 *);
@@ -830,7 +826,7 @@ 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 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_CopyHome(const struct http *hp);
void http_Unset(struct http *hp, const char *hdr);
void http_CollectHdr(struct http *hp, const char *hdr);
diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c
index 267e7ba..6e86538 100644
--- a/bin/varnishd/cache/cache_backend.c
+++ b/bin/varnishd/cache/cache_backend.c
@@ -65,14 +65,12 @@ struct vdi_simple {
* Create default Host: header for backend request
*/
void
-VDI_AddHostHeader(struct worker *wrk, const struct vbc *vbc)
+VDI_AddHostHeader(struct http *hp, const struct vbc *vbc)
{
- CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
- CHECK_OBJ_NOTNULL(wrk->busyobj->bereq, HTTP_MAGIC);
CHECK_OBJ_NOTNULL(vbc, VBC_MAGIC);
CHECK_OBJ_NOTNULL(vbc->vdis, VDI_SIMPLE_MAGIC);
- http_PrintfHeader(wrk, vbc->vsl_id, wrk->busyobj->bereq,
+ http_PrintfHeader(hp,
"Host: %s", vbc->vdis->vrt->hosthdr);
}
diff --git a/bin/varnishd/cache/cache_center.c b/bin/varnishd/cache/cache_center.c
index 54a883b..8aa80d1 100644
--- a/bin/varnishd/cache/cache_center.c
+++ b/bin/varnishd/cache/cache_center.c
@@ -501,17 +501,16 @@ cnt_error(struct sess *sp, struct worker *wrk, struct req *req)
if (req->err_code < 100 || req->err_code > 999)
req->err_code = 501;
- http_PutProtocol(wrk, sp->vsl_id, h, "HTTP/1.1");
+ http_PutProtocol(h, "HTTP/1.1");
http_PutStatus(h, req->err_code);
VTIM_format(W_TIM_real(wrk), date);
- http_PrintfHeader(wrk, sp->vsl_id, h, "Date: %s", date);
- http_SetHeader(wrk, sp->vsl_id, h, "Server: Varnish");
+ http_PrintfHeader(h, "Date: %s", date);
+ http_SetHeader(h, "Server: Varnish");
if (req->err_reason != NULL)
- http_PutResponse(wrk, sp->vsl_id, h, req->err_reason);
+ http_PutResponse(h, req->err_reason);
else
- http_PutResponse(wrk, sp->vsl_id, h,
- http_StatusMessage(req->err_code));
+ http_PutResponse(h, http_StatusMessage(req->err_code));
VCL_error_method(sp);
if (req->handling == VCL_RET_RESTART &&
@@ -745,8 +744,7 @@ cnt_prepfetch(struct sess *sp, struct worker *wrk, struct req *req)
/* If we do gzip, add the C-E header */
if (bo->do_gzip)
- http_SetHeader(wrk, sp->vsl_id, bo->beresp,
- "Content-Encoding: gzip");
+ http_SetHeader(bo->beresp, "Content-Encoding: gzip");
/* But we can't do both at the same time */
assert(bo->do_gzip == 0 || bo->do_gunzip == 0);
@@ -839,7 +837,7 @@ cnt_prepfetch(struct sess *sp, struct worker *wrk, struct req *req)
hp2->logtag = HTTP_Obj;
http_FilterResp(hp, hp2, pass ? HTTPH_R_PASS : HTTPH_A_INS);
- http_CopyHome(wrk, sp->vsl_id, hp2);
+ http_CopyHome(hp2);
if (http_GetHdr(hp, H_Last_Modified, &b))
req->obj->last_modified = VTIM_parse(b);
@@ -1233,8 +1231,7 @@ cnt_miss(struct sess *sp, struct worker *wrk, struct req *req)
* the minority of clients which don't.
*/
http_Unset(wrk->busyobj->bereq, H_Accept_Encoding);
- http_SetHeader(wrk, sp->vsl_id, wrk->busyobj->bereq,
- "Accept-Encoding: gzip");
+ http_SetHeader(wrk->busyobj->bereq, "Accept-Encoding: gzip");
}
VCL_miss_method(sp);
@@ -1400,7 +1397,7 @@ DOT hash -> lookup [label="hash",style=bold,color=green]
*/
static int
-cnt_recv(struct sess *sp, struct worker *wrk, struct req *req)
+cnt_recv(struct sess *sp, const struct worker *wrk, struct req *req)
{
unsigned recv_handling;
struct SHA256Context sha256ctx;
@@ -1444,8 +1441,7 @@ cnt_recv(struct sess *sp, struct worker *wrk, struct req *req)
(recv_handling != VCL_RET_PASS)) {
if (RFC2616_Req_Gzip(sp)) {
http_Unset(req->http, H_Accept_Encoding);
- http_SetHeader(wrk, sp->vsl_id, req->http,
- "Accept-Encoding: gzip");
+ http_SetHeader(req->http, "Accept-Encoding: gzip");
} else {
http_Unset(req->http, H_Accept_Encoding);
}
diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c
index 8ef35a3..360a70f 100644
--- a/bin/varnishd/cache/cache_esi_deliver.c
+++ b/bin/varnishd/cache/cache_esi_deliver.c
@@ -73,7 +73,7 @@ ved_include(struct sess *sp, const char *src, const char *host)
if (host != NULL && *host != '\0') {
http_Unset(sp->req->http, H_Host);
http_Unset(sp->req->http, H_If_Modified_Since);
- http_SetHeader(w, sp->vsl_id, sp->req->http, host);
+ http_SetHeader(sp->req->http, host);
}
/*
* XXX: We should decide if we should cache the director
diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index 327ae0a..f5995ca 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -393,8 +393,8 @@ FetchHdr(struct sess *sp, int need_host_hdr, int sendbody)
struct http_conn *htc;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
- CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC);
wrk = sp->wrk;
+ CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC);
htc = &wrk->busyobj->htc;
@@ -408,12 +408,12 @@ FetchHdr(struct sess *sp, int need_host_hdr, int sendbody)
hp = wrk->busyobj->bereq;
- sp->wrk->busyobj->vbc = VDI_GetFd(NULL, sp);
- if (sp->wrk->busyobj->vbc == NULL) {
+ wrk->busyobj->vbc = VDI_GetFd(NULL, sp);
+ if (wrk->busyobj->vbc == NULL) {
WSP(sp, SLT_FetchError, "no backend connection");
return (-1);
}
- vc = sp->wrk->busyobj->vbc;
+ vc = wrk->busyobj->vbc;
if (vc->recycled)
retry = 1;
@@ -423,7 +423,7 @@ FetchHdr(struct sess *sp, int need_host_hdr, int sendbody)
* because the backend may be chosen by a director.
*/
if (need_host_hdr)
- VDI_AddHostHeader(sp->wrk, vc);
+ VDI_AddHostHeader(wrk->busyobj->bereq, vc);
(void)VTCP_blocking(vc->fd); /* XXX: we should timeout instead */
WRW_Reserve(wrk, &vc->fd);
@@ -434,7 +434,7 @@ FetchHdr(struct sess *sp, int need_host_hdr, int sendbody)
if (WRW_FlushRelease(wrk) || i > 0) {
WSP(sp, SLT_FetchError, "backend write error: %d (%s)",
errno, strerror(errno));
- VDI_CloseFd(sp->wrk, &sp->wrk->busyobj->vbc);
+ VDI_CloseFd(wrk, &wrk->busyobj->vbc);
/* XXX: other cleanup ? */
return (retry);
}
@@ -458,7 +458,7 @@ FetchHdr(struct sess *sp, int need_host_hdr, int sendbody)
if (i < 0) {
WSP(sp, SLT_FetchError, "http first read error: %d %d (%s)",
i, errno, strerror(errno));
- VDI_CloseFd(sp->wrk, &sp->wrk->busyobj->vbc);
+ VDI_CloseFd(wrk, &wrk->busyobj->vbc);
/* XXX: other cleanup ? */
/* Retryable if we never received anything */
return (i == -1 ? retry : -1);
@@ -472,7 +472,7 @@ FetchHdr(struct sess *sp, int need_host_hdr, int sendbody)
WSP(sp, SLT_FetchError,
"http first read error: %d %d (%s)",
i, errno, strerror(errno));
- VDI_CloseFd(sp->wrk, &sp->wrk->busyobj->vbc);
+ VDI_CloseFd(wrk, &wrk->busyobj->vbc);
/* XXX: other cleanup ? */
return (-1);
}
@@ -482,7 +482,7 @@ FetchHdr(struct sess *sp, int need_host_hdr, int sendbody)
if (http_DissectResponse(hp, htc)) {
WSP(sp, SLT_FetchError, "http format error");
- VDI_CloseFd(sp->wrk, &sp->wrk->busyobj->vbc);
+ VDI_CloseFd(wrk, &wrk->busyobj->vbc);
/* XXX: other cleanup ? */
return (-1);
}
@@ -614,8 +614,7 @@ FetchBody(struct worker *wrk, struct object *obj)
if (mklen > 0) {
http_Unset(obj->http, H_Content_Length);
- http_PrintfHeader(wrk, bo->vbc->vsl_id, obj->http,
- "Content-Length: %zd", obj->len);
+ http_PrintfHeader(obj->http, "Content-Length: %zd", obj->len);
}
if (cls)
diff --git a/bin/varnishd/cache/cache_http.c b/bin/varnishd/cache/cache_http.c
index 2a97829..de71ada 100644
--- a/bin/varnishd/cache/cache_http.c
+++ b/bin/varnishd/cache/cache_http.c
@@ -865,8 +865,7 @@ http_FilterReq(const struct sess *sp, unsigned how)
else
http_linkh(hp, sp->req->http, HTTP_HDR_PROTO);
http_filterfields(hp, sp->req->http, how);
- http_PrintfHeader(sp->wrk, sp->vsl_id, hp,
- "X-Varnish: %u", sp->req->xid);
+ http_PrintfHeader(hp, "X-Varnish: %u", sp->req->xid);
}
/*--------------------------------------------------------------------*/
@@ -889,7 +888,7 @@ http_FilterResp(const struct http *fm, struct http *to, unsigned how)
*/
void
-http_CopyHome(struct worker *w, unsigned vsl_id, const struct http *hp)
+http_CopyHome(const struct http *hp)
{
unsigned u, l;
char *p;
@@ -911,7 +910,7 @@ http_CopyHome(struct worker *w, unsigned vsl_id, const struct http *hp)
} else {
/* XXX This leaves a slot empty */
VSC_C_main->losthdr++;
- WSLR(w->vsl, SLT_LostHeader, vsl_id, hp->hd[u]);
+ WSLR(hp->vsl, SLT_LostHeader, -1, hp->hd[u]);
hp->hd[u].b = NULL;
hp->hd[u].e = NULL;
}
@@ -935,14 +934,13 @@ http_ClrHeader(struct http *to)
/*--------------------------------------------------------------------*/
void
-http_SetHeader(struct worker *w, unsigned vsl_id, struct http *to,
- const char *hdr)
+http_SetHeader(struct http *to, const char *hdr)
{
CHECK_OBJ_NOTNULL(to, HTTP_MAGIC);
if (to->nhd >= to->shd) {
VSC_C_main->losthdr++;
- WSL(w->vsl, SLT_LostHeader, vsl_id, "%s", hdr);
+ WSL(to->vsl, SLT_LostHeader, -1, "%s", hdr);
return;
}
http_SetH(to, to->nhd++, hdr);
@@ -951,8 +949,7 @@ http_SetHeader(struct worker *w, unsigned vsl_id, struct http *to,
/*--------------------------------------------------------------------*/
static void
-http_PutField(struct worker *w, unsigned vsl_id, const struct http *to,
- int field, const char *string)
+http_PutField(const struct http *to, int field, const char *string)
{
char *p;
unsigned l;
@@ -961,7 +958,7 @@ http_PutField(struct worker *w, unsigned vsl_id, const struct http *to,
l = strlen(string);
p = WS_Alloc(to->ws, l + 1);
if (p == NULL) {
- WSL(w->vsl, SLT_LostHeader, vsl_id, "%s", string);
+ WSL(to->vsl, SLT_LostHeader, -1, "%s", string);
to->hd[field].b = NULL;
to->hd[field].e = NULL;
to->hdf[field] = 0;
@@ -974,11 +971,10 @@ http_PutField(struct worker *w, unsigned vsl_id, const struct http *to,
}
void
-http_PutProtocol(struct worker *w, unsigned vsl_id, const struct http *to,
- const char *protocol)
+http_PutProtocol(const struct http *to, const char *protocol)
{
- http_PutField(w, vsl_id, to, HTTP_HDR_PROTO, protocol);
+ http_PutField(to, HTTP_HDR_PROTO, protocol);
if (to->hd[HTTP_HDR_PROTO].b == NULL)
http_SetH(to, HTTP_HDR_PROTO, "HTTP/1.1");
Tcheck(to->hd[HTTP_HDR_PROTO]);
@@ -993,19 +989,17 @@ http_PutStatus(struct http *to, uint16_t status)
}
void
-http_PutResponse(struct worker *w, unsigned vsl_id, const struct http *to,
- const char *response)
+http_PutResponse(const struct http *to, const char *response)
{
- http_PutField(w, vsl_id, to, HTTP_HDR_RESPONSE, response);
+ http_PutField(to, HTTP_HDR_RESPONSE, response);
if (to->hd[HTTP_HDR_RESPONSE].b == NULL)
http_SetH(to, HTTP_HDR_RESPONSE, "Lost Response");
Tcheck(to->hd[HTTP_HDR_RESPONSE]);
}
void
-http_PrintfHeader(struct worker *w, unsigned vsl_id, struct http *to,
- const char *fmt, ...)
+http_PrintfHeader(struct http *to, const char *fmt, ...)
{
va_list ap;
unsigned l, n;
@@ -1017,7 +1011,7 @@ http_PrintfHeader(struct worker *w, unsigned vsl_id, struct http *to,
va_end(ap);
if (n + 1 >= l || to->nhd >= to->shd) {
VSC_C_main->losthdr++;
- WSL(w->vsl, SLT_LostHeader, vsl_id, "%s", to->ws->f);
+ WSL(to->vsl, SLT_LostHeader, -1, "%s", to->ws->f);
WS_Release(to->ws, 0);
} else {
to->hd[to->nhd].b = to->ws->f;
diff --git a/bin/varnishd/cache/cache_response.c b/bin/varnishd/cache/cache_response.c
index df9c137..148a73c 100644
--- a/bin/varnishd/cache/cache_response.c
+++ b/bin/varnishd/cache/cache_response.c
@@ -90,13 +90,12 @@ res_dorange(const struct sess *sp, const char *r, ssize_t *plow, ssize_t *phigh)
if (low > high)
return;
- http_PrintfHeader(sp->wrk, sp->vsl_id, req->resp,
- "Content-Range: bytes %jd-%jd/%jd",
+ http_PrintfHeader(req->resp, "Content-Range: bytes %jd-%jd/%jd",
(intmax_t)low, (intmax_t)high, (intmax_t)req->obj->len);
http_Unset(req->resp, H_Content_Length);
assert(req->res_mode & RES_LEN);
- http_PrintfHeader(sp->wrk, sp->vsl_id, req->resp,
- "Content-Length: %jd", (intmax_t)(1 + high - low));
+ http_PrintfHeader(req->resp, "Content-Length: %jd",
+ (intmax_t)(1 + high - low));
http_SetResp(req->resp, "HTTP/1.1", 206, "Partial Content");
*plow = low;
@@ -123,29 +122,25 @@ RES_BuildHttp(const struct sess *sp)
http_Unset(req->resp, H_Content_Length);
} else if (cache_param->http_range_support) {
/* We only accept ranges if we know the length */
- http_SetHeader(sp->wrk, sp->vsl_id, req->resp,
- "Accept-Ranges: bytes");
+ http_SetHeader(req->resp, "Accept-Ranges: bytes");
}
if (req->res_mode & RES_CHUNKED)
- http_SetHeader(sp->wrk, sp->vsl_id, req->resp,
- "Transfer-Encoding: chunked");
+ http_SetHeader(req->resp, "Transfer-Encoding: chunked");
VTIM_format(VTIM_real(), time_str);
- http_PrintfHeader(sp->wrk, sp->vsl_id, req->resp,
- "Date: %s", time_str);
+ http_PrintfHeader(req->resp, "Date: %s", time_str);
if (req->xid != req->obj->xid)
- http_PrintfHeader(sp->wrk, sp->vsl_id, req->resp,
+ http_PrintfHeader(req->resp,
"X-Varnish: %u %u", req->xid, req->obj->xid);
else
- http_PrintfHeader(sp->wrk, sp->vsl_id, req->resp,
- "X-Varnish: %u", req->xid);
- http_PrintfHeader(sp->wrk, sp->vsl_id, req->resp, "Age: %.0f",
+ http_PrintfHeader(req->resp, "X-Varnish: %u", req->xid);
+ http_PrintfHeader(req->resp, "Age: %.0f",
req->obj->exp.age + req->t_resp -
req->obj->exp.entered);
- http_SetHeader(sp->wrk, sp->vsl_id, req->resp, "Via: 1.1 varnish");
- http_PrintfHeader(sp->wrk, sp->vsl_id, req->resp, "Connection: %s",
+ http_SetHeader(req->resp, "Via: 1.1 varnish");
+ http_PrintfHeader(req->resp, "Connection: %s",
req->doclose ? "close" : "keep-alive");
}
@@ -337,7 +332,7 @@ RES_StreamStart(struct sess *sp)
if (!(req->res_mode & RES_CHUNKED) &&
sp->wrk->busyobj->h_content_length != NULL)
- http_PrintfHeader(sp->wrk, sp->vsl_id, sp->req->resp,
+ http_PrintfHeader(sp->req->resp,
"Content-Length: %s", sp->wrk->busyobj->h_content_length);
sp->wrk->acct_tmp.hdrbytes +=
diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c
index d69c7fb..6271e49 100644
--- a/bin/varnishd/cache/cache_vrt.c
+++ b/bin/varnishd/cache/cache_vrt.c
@@ -231,7 +231,7 @@ VRT_SetHdr(const struct sess *sp , enum gethdr_e where, const char *hdr,
WSP(sp, SLT_LostHeader, "%s", hdr + 1);
} else {
http_Unset(hp, hdr);
- http_SetHeader(sp->wrk, sp->vsl_id, hp, b);
+ http_SetHeader(hp, b);
}
}
va_end(ap);
@@ -417,7 +417,7 @@ VRT_synth_page(const struct sess *sp, unsigned flags, const char *str, ...)
va_end(ap);
SMS_Finish(sp->req->obj);
http_Unset(sp->req->obj->http, H_Content_Length);
- http_PrintfHeader(sp->wrk, sp->vsl_id, sp->req->obj->http,
+ http_PrintfHeader(sp->req->obj->http,
"Content-Length: %zd", sp->req->obj->len);
}
diff --git a/bin/varnishd/flint.lnt b/bin/varnishd/flint.lnt
index 15f91df..97ff04a 100644
--- a/bin/varnishd/flint.lnt
+++ b/bin/varnishd/flint.lnt
@@ -1,7 +1,7 @@
-d__flexelint_v9__=1
-printf(3, VSL)
--printf(4, http_PrintfHeader)
+-printf(2, http_PrintfHeader)
-printf(4, WSL)
-printf(3, WSLB)
-printf(2, VSB_printf)
More information about the varnish-commit
mailing list