[master] b9708eac8 Fix a recently introduced issue with logging of ESI request headers.
Poul-Henning Kamp
phk at FreeBSD.org
Mon Jan 14 23:36:08 UTC 2019
commit b9708eac809feac0358ba2156aca0a5000582eb2
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Mon Jan 14 21:46:40 2019 +0000
Fix a recently introduced issue with logging of ESI request headers.
diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 86db641dc..ff5fa29da 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -595,7 +595,8 @@ extern pthread_t cli_thread;
/* cache_http.c */
unsigned HTTP_estimate(unsigned nhttp);
-void HTTP_Copy(struct http *to, const struct http * const fm);
+void HTTP_Clone(struct http *to, const struct http * const fm);
+void HTTP_Dup(struct http *to, const struct http * const fm);
struct http *HTTP_create(void *p, uint16_t nhttp, unsigned);
const char *http_Status2Reason(unsigned, const char **);
unsigned http_EstimateWS(const struct http *fm, unsigned how);
diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c
index b3dd3c0c4..f164b4bc5 100644
--- a/bin/varnishd/cache/cache_esi_deliver.c
+++ b/bin/varnishd/cache/cache_esi_deliver.c
@@ -141,7 +141,7 @@ ved_include(struct req *preq, const char *src, const char *host,
req->top = preq->top;
HTTP_Setup(req->http, req->ws, req->vsl, SLT_ReqMethod);
- HTTP_Copy(req->http, preq->http0);
+ HTTP_Dup(req->http, preq->http0);
http_SetH(req->http, HTTP_HDR_URL, src);
if (host != NULL && *host != '\0') {
diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index 1e42d0201..57aa5bd0f 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -208,7 +208,7 @@ vbf_stp_mkbereq(struct worker *wrk, struct busyobj *bo)
HTTP_Setup(bo->bereq, bo->ws, bo->vsl, SLT_BereqMethod);
bo->ws_bo = WS_Snapshot(bo->ws);
- HTTP_Copy(bo->bereq, bo->bereq0);
+ HTTP_Clone(bo->bereq, bo->bereq0);
if (bo->req->req_body_status == REQ_BODY_NONE) {
bo->req = NULL;
diff --git a/bin/varnishd/cache/cache_http.c b/bin/varnishd/cache/cache_http.c
index 34cd11a02..534cd5d2e 100644
--- a/bin/varnishd/cache/cache_http.c
+++ b/bin/varnishd/cache/cache_http.c
@@ -190,19 +190,39 @@ http_Teardown(struct http *hp)
memset(hp->hdf, 0, sizeof *hp->hdf * hp->shd);
}
-/*--------------------------------------------------------------------*/
+/*--------------------------------------------------------------------
+ * Duplicate the http content into another http
+ * We cannot just memcpy the struct because the hd & hdf are private
+ * storage to the struct http.
+ */
void
-HTTP_Copy(struct http *to, const struct http * const fm)
+HTTP_Dup(struct http *to, const struct http * const fm)
{
assert(fm->nhd <= to->shd);
- memcpy(&to->nhd, &fm->nhd, sizeof *to - offsetof(struct http, nhd));
memcpy(to->hd, fm->hd, fm->nhd * sizeof *to->hd);
memcpy(to->hdf, fm->hdf, fm->nhd * sizeof *to->hdf);
+ to->nhd = fm->nhd;
+ to->logtag = fm->logtag;
+ to->status = fm->status;
to->protover = fm->protover;
}
+
+/*--------------------------------------------------------------------
+ * Clone the entire http structure, including vsl & ws
+ */
+
+void
+HTTP_Clone(struct http *to, const struct http * const fm)
+{
+
+ HTTP_Dup(to, fm);
+ to->vsl = fm->vsl;
+ to->ws = fm->ws;
+}
+
/*--------------------------------------------------------------------*/
void
diff --git a/bin/varnishd/cache/cache_req.c b/bin/varnishd/cache/cache_req.c
index d2f3c2d31..11ada9c1e 100644
--- a/bin/varnishd/cache/cache_req.c
+++ b/bin/varnishd/cache/cache_req.c
@@ -189,7 +189,7 @@ Req_Rollback(struct req *req)
{
VCL_TaskLeave(req->vcl, req->privs);
VCL_TaskEnter(req->vcl, req->privs);
- HTTP_Copy(req->http, req->http0);
+ HTTP_Clone(req->http, req->http0);
if (WS_Overflowed(req->ws))
req->wrk->stats->ws_client_overflow++;
WS_Reset(req->ws, req->ws_req);
diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c
index f11fd96bf..9650ec59d 100644
--- a/bin/varnishd/cache/cache_req_fsm.c
+++ b/bin/varnishd/cache/cache_req_fsm.c
@@ -94,7 +94,7 @@ cnt_transport(struct worker *wrk, struct req *req)
}
req->ws_req = WS_Snapshot(req->ws);
- HTTP_Copy(req->http0, req->http); // For ESI & restart
+ HTTP_Clone(req->http0, req->http); // For ESI & restart
req->req_step = R_STP_RECV;
return (REQ_FSM_MORE);
}
diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c
index 9ab637fed..e1ac810c4 100644
--- a/bin/varnishd/cache/cache_vrt.c
+++ b/bin/varnishd/cache/cache_vrt.c
@@ -639,7 +639,7 @@ VRT_Rollback(VRT_CTX, VCL_HTTP hp)
// -> VBO_Rollback ?
VCL_TaskLeave(ctx->bo->vcl, ctx->bo->privs);
VCL_TaskEnter(ctx->bo->vcl, ctx->bo->privs);
- HTTP_Copy(ctx->bo->bereq, ctx->bo->bereq0);
+ HTTP_Clone(ctx->bo->bereq, ctx->bo->bereq0);
WS_Reset(ctx->bo->bereq->ws, ctx->bo->ws_bo);
WS_Reset(ctx->bo->ws, ctx->bo->ws_bo);
} else
diff --git a/include/vrt.h b/include/vrt.h
index 19bdb7b08..35d9dcaa1 100644
--- a/include/vrt.h
+++ b/include/vrt.h
@@ -52,6 +52,10 @@
* binary/load-time compatible, increment MAJOR version
*
*
+ * 9.0 (scheduled for 2019-03-15)
+ * HTTP_Copy() removed
+ * HTTP_Dup() added
+ * HTTP_Clone() added
* 8.0 (2018-09-15)
* VRT_Strands() added
* VRT_StrandsWS() added
More information about the varnish-commit
mailing list