[master] c799158 Avoid the indirection of the bereq, beresp and resp http structures, it no longer saves us memory.
Poul-Henning Kamp
phk at varnish-cache.org
Mon Mar 7 11:34:15 CET 2011
commit c7991588e3eab660f295fd30a54a5bf17166c2df
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Mon Mar 7 10:33:49 2011 +0000
Avoid the indirection of the bereq,beresp and resp http structures,
it no longer saves us memory.
diff --git a/bin/varnishd/cache.h b/bin/varnishd/cache.h
index ca1cdff..66fa848 100644
--- a/bin/varnishd/cache.h
+++ b/bin/varnishd/cache.h
@@ -271,7 +271,6 @@ struct worker {
struct http_conn htc[1];
struct ws ws[1];
- struct http *http[3];
struct http *bereq;
struct http *beresp;
struct http *resp;
diff --git a/bin/varnishd/cache_center.c b/bin/varnishd/cache_center.c
index 30ad63a..981e4f2 100644
--- a/bin/varnishd/cache_center.c
+++ b/bin/varnishd/cache_center.c
@@ -213,7 +213,6 @@ cnt_deliver(struct sess *sp)
sp->obj->last_lru = sp->t_resp;
sp->obj->last_use = sp->t_resp; /* XXX: locking ? */
}
- sp->wrk->resp = sp->wrk->http[2];
http_Setup(sp->wrk->resp, sp->wrk->ws);
RES_BuildHttp(sp);
VCL_deliver_method(sp);
@@ -227,9 +226,9 @@ cnt_deliver(struct sess *sp)
AZ(sp->obj);
sp->restarts++;
sp->director = NULL;
- sp->wrk->bereq = NULL;
- sp->wrk->beresp = NULL;
- sp->wrk->resp = NULL;
+ http_Setup(sp->wrk->bereq, NULL);
+ http_Setup(sp->wrk->beresp, NULL);
+ http_Setup(sp->wrk->resp, NULL);
sp->step = STP_RECV;
return (0);
default:
@@ -243,7 +242,7 @@ cnt_deliver(struct sess *sp)
AZ(sp->wrk->wfd);
(void)HSH_Deref(sp->wrk, NULL, &sp->obj);
- sp->wrk->resp = NULL;
+ http_Setup(sp->wrk->resp, NULL);
sp->step = STP_DONE;
return (0);
}
@@ -425,7 +424,7 @@ cnt_error(struct sess *sp)
assert(sp->handling == VCL_RET_DELIVER);
sp->err_code = 0;
sp->err_reason = NULL;
- sp->wrk->bereq = NULL;
+ http_Setup(sp->wrk->bereq, NULL);
sp->step = STP_DELIVER;
return (0);
}
@@ -477,8 +476,6 @@ cnt_fetch(struct sess *sp)
AZ(sp->wrk->h_content_length);
AZ(sp->wrk->do_close);
- /* sp->wrk->http[0] is (still) bereq */
- sp->wrk->beresp = sp->wrk->http[1];
http_Setup(sp->wrk->beresp, sp->wrk->ws);
i = FetchHdr(sp);
@@ -516,8 +513,8 @@ cnt_fetch(struct sess *sp)
AZ(sp->obj);
sp->wrk->do_close = 0;
sp->wrk->h_content_length = NULL;
- sp->wrk->bereq = NULL;
- sp->wrk->beresp = NULL;
+ http_Setup(sp->wrk->bereq, NULL);
+ http_Setup(sp->wrk->beresp, NULL);
sp->err_code = 503;
sp->step = STP_ERROR;
return (0);
@@ -704,8 +701,8 @@ cnt_fetch(struct sess *sp)
sp->wrk->do_close = 0;
sp->wrk->h_content_length = NULL;
- sp->wrk->bereq = NULL;
- sp->wrk->beresp = NULL;
+ http_Setup(sp->wrk->bereq, NULL);
+ http_Setup(sp->wrk->beresp, NULL);
sp->wrk->vfp = NULL;
AZ(sp->wrk->wfd);
AZ(sp->vbc);
@@ -812,7 +809,8 @@ cnt_hit(struct sess *sp)
if (sp->handling == VCL_RET_DELIVER) {
/* Dispose of any body part of the request */
(void)FetchReqBody(sp);
- sp->wrk->bereq = NULL;
+ AZ(sp->wrk->bereq->ws);
+ AZ(sp->wrk->beresp->ws);
sp->step = STP_DELIVER;
return (0);
}
@@ -953,7 +951,6 @@ cnt_miss(struct sess *sp)
AZ(sp->obj);
AN(sp->objcore);
WS_Reset(sp->wrk->ws, NULL);
- sp->wrk->bereq = sp->wrk->http[0];
http_Setup(sp->wrk->bereq, sp->wrk->ws);
http_FilterHeader(sp, HTTPH_R_FETCH);
http_ForceGet(sp->wrk->bereq);
@@ -1035,7 +1032,6 @@ cnt_pass(struct sess *sp)
AZ(sp->obj);
WS_Reset(sp->wrk->ws, NULL);
- sp->wrk->bereq = sp->wrk->http[0];
http_Setup(sp->wrk->bereq, sp->wrk->ws);
http_FilterHeader(sp, HTTPH_R_PASS);
@@ -1088,7 +1084,6 @@ cnt_pipe(struct sess *sp)
sp->acct_tmp.pipe++;
WS_Reset(sp->wrk->ws, NULL);
- sp->wrk->bereq = sp->wrk->http[0];
http_Setup(sp->wrk->bereq, sp->wrk->ws);
http_FilterHeader(sp, HTTPH_R_PIPE);
@@ -1100,7 +1095,7 @@ cnt_pipe(struct sess *sp)
PipeSession(sp);
AZ(sp->wrk->wfd);
- sp->wrk->bereq = NULL;
+ http_Setup(sp->wrk->bereq, NULL);
sp->step = STP_DONE;
return (0);
}
diff --git a/bin/varnishd/cache_panic.c b/bin/varnishd/cache_panic.c
index 55c04d5..3405d92 100644
--- a/bin/varnishd/cache_panic.c
+++ b/bin/varnishd/cache_panic.c
@@ -198,10 +198,12 @@ pan_wrk(const struct worker *wrk)
vsb_printf(vsp, " worker = %p {\n", wrk);
pan_ws(wrk->ws, 4);
- if (wrk->bereq != NULL)
+ if (wrk->bereq->ws != NULL)
pan_http("bereq", wrk->bereq, 4);
- if (wrk->beresp != NULL)
+ if (wrk->beresp->ws != NULL)
pan_http("beresp", wrk->beresp, 4);
+ if (wrk->resp->ws != NULL)
+ pan_http("resp", wrk->resp, 4);
vsb_printf(vsp, " },\n");
}
diff --git a/bin/varnishd/cache_pool.c b/bin/varnishd/cache_pool.c
index 361743f..0c80772 100644
--- a/bin/varnishd/cache_pool.c
+++ b/bin/varnishd/cache_pool.c
@@ -140,9 +140,9 @@ wrk_thread_real(struct wq *qp, unsigned shm_workspace, unsigned sess_workspace,
w->wlb = w->wlp = wlog;
w->wle = wlog + (sizeof wlog) / 4;
w->sha256ctx = &sha256;
- w->http[0] = HTTP_create(http0, nhttp);
- w->http[1] = HTTP_create(http1, nhttp);
- w->http[2] = HTTP_create(http2, nhttp);
+ w->bereq = HTTP_create(http0, nhttp);
+ w->beresp = HTTP_create(http1, nhttp);
+ w->resp = HTTP_create(http2, nhttp);
w->iov = iov;
w->siov = siov;
AZ(pthread_cond_init(&w->cond, NULL));
@@ -155,6 +155,9 @@ wrk_thread_real(struct wq *qp, unsigned shm_workspace, unsigned sess_workspace,
qp->nthr++;
stats_clean = 1;
while (1) {
+ CHECK_OBJ_NOTNULL(w->bereq, HTTP_MAGIC);
+ CHECK_OBJ_NOTNULL(w->beresp, HTTP_MAGIC);
+ CHECK_OBJ_NOTNULL(w->resp, HTTP_MAGIC);
CHECK_OBJ_NOTNULL(w, WORKER_MAGIC);
/* Process queued requests, if any */
@@ -178,15 +181,14 @@ wrk_thread_real(struct wq *qp, unsigned shm_workspace, unsigned sess_workspace,
AN(w->wrq->func);
w->lastused = NAN;
WS_Reset(w->ws, NULL);
- w->bereq = NULL;
- w->beresp = NULL;
- w->resp = NULL;
w->storage_hint = NULL;
+
w->wrq->func(w, w->wrq->priv);
- AZ(w->bereq);
- AZ(w->beresp);
- AZ(w->resp);
+
WS_Assert(w->ws);
+ AZ(w->bereq->ws);
+ AZ(w->beresp->ws);
+ AZ(w->resp->ws);
AZ(w->wfd);
AZ(w->storage_hint);
assert(w->wlp == w->wlb);
More information about the varnish-commit
mailing list