[master] 7ffb0af Allocate bo->htc from the bo->ws when we needed it.
Poul-Henning Kamp
phk at FreeBSD.org
Mon Oct 13 11:37:33 CEST 2014
commit 7ffb0afa7ab735b38ad1daadf9697876774a7f55
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Mon Oct 13 09:08:05 2014 +0000
Allocate bo->htc from the bo->ws when we needed it.
diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 839516d..f08631f 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -496,7 +496,7 @@ struct busyobj {
struct objcore *ims_oc;
struct objcore *fetch_objcore;
- struct http_conn htc[1];
+ struct http_conn *htc;
struct pool_task fetch_task;
diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c
index 0f141e2..a42f731 100644
--- a/bin/varnishd/cache/cache_backend.c
+++ b/bin/varnishd/cache/cache_backend.c
@@ -352,6 +352,12 @@ vbe_dir_getfd(const struct director *d, struct busyobj *bo)
CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC);
CAST_OBJ_NOTNULL(vs, d->priv, VDI_SIMPLE_MAGIC);
+
+ AZ(bo->htc);
+ bo->htc = WS_Alloc(bo->ws, sizeof *bo->htc);
+ memset(bo->htc, 0, sizeof *bo->htc);
+ bo->htc->magic = HTTP_CONN_MAGIC;
+
vc = vbe_GetVbe(bo, vs);
if (vc != NULL) {
FIND_TMO(first_byte_timeout,
@@ -390,6 +396,7 @@ vbe_dir_gethdrs(const struct director *d, struct worker *wrk,
bo->vbc = vbe_dir_getfd(d, bo);
if (bo->vbc == NULL) {
VSLb(bo->vsl, SLT_FetchError, "no backend connection");
+ bo->htc = NULL;
return (-1);
}
@@ -406,6 +413,7 @@ vbe_dir_gethdrs(const struct director *d, struct worker *wrk,
bo->vbc = vbe_dir_getfd(d, bo);
if (bo->vbc == NULL) {
VSLb(bo->vsl, SLT_FetchError, "no backend connection");
+ bo->htc = NULL;
return (-1);
}
i = V1F_fetch_hdr(wrk, bo);
@@ -442,6 +450,8 @@ vbe_dir_finish(const struct director *d, struct worker *wrk,
CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
+ CHECK_OBJ_NOTNULL(bo->htc, HTTP_CONN_MAGIC);
+ bo->htc = NULL;
if (bo->vbc == NULL)
return;
bp = bo->vbc->backend;
diff --git a/bin/varnishd/cache/cache_busyobj.c b/bin/varnishd/cache/cache_busyobj.c
index 4256400..e605ef4 100644
--- a/bin/varnishd/cache/cache_busyobj.c
+++ b/bin/varnishd/cache/cache_busyobj.c
@@ -82,6 +82,7 @@ VBO_Free(struct busyobj **bop)
bo = *bop;
*bop = NULL;
CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
+ AZ(bo->htc);
AZ(bo->refcount);
AZ(pthread_cond_destroy(&bo->cond));
Lck_Delete(&bo->mtx);
@@ -187,6 +188,8 @@ VBO_DerefBusyObj(struct worker *wrk, struct busyobj **pbo)
if (r)
return;
+ AZ(bo->htc);
+
VSLb(bo->vsl, SLT_BereqAcct, "%ju %ju %ju %ju %ju %ju",
(uintmax_t)bo->acct.bereq_hdrbytes,
(uintmax_t)bo->acct.bereq_bodybytes,
diff --git a/bin/varnishd/http1/cache_http1_fetch.c b/bin/varnishd/http1/cache_http1_fetch.c
index 2d63159..64bb63a 100644
--- a/bin/varnishd/http1/cache_http1_fetch.c
+++ b/bin/varnishd/http1/cache_http1_fetch.c
@@ -87,6 +87,7 @@ V1F_fetch_hdr(struct worker *wrk, struct busyobj *bo)
CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
+ CHECK_OBJ_NOTNULL(bo->htc, HTTP_CONN_MAGIC);
CHECK_OBJ_NOTNULL(bo->vbc, VBC_MAGIC);
CHECK_OBJ_ORNULL(bo->req, REQ_MAGIC);
More information about the varnish-commit
mailing list