[master] 624b373 Move sha256 hash context from worker to req
Poul-Henning Kamp
phk at varnish-cache.org
Mon Dec 26 11:22:10 CET 2011
commit 624b3731b13b23fbd60499170dfb2458ef111b6e
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Mon Dec 26 10:12:24 2011 +0000
Move sha256 hash context from worker to req
diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 71b2c83..372a32d 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -324,9 +324,6 @@ struct worker {
uint32_t *wlb, *wlp, *wle;
unsigned wlr;
- /* Lookup stuff */
- struct SHA256Context *sha256ctx;
-
struct ws ws[1];
struct busyobj *busyobj;
@@ -622,6 +619,9 @@ struct req {
struct ws ws[1];
struct object *obj;
struct objcore *objcore;
+ /* Lookup stuff */
+ struct SHA256Context *sha256ctx;
+
};
/*--------------------------------------------------------------------*/
diff --git a/bin/varnishd/cache/cache_center.c b/bin/varnishd/cache/cache_center.c
index 8ee4470..7e9c77f 100644
--- a/bin/varnishd/cache/cache_center.c
+++ b/bin/varnishd/cache/cache_center.c
@@ -1502,10 +1502,10 @@ cnt_recv(struct sess *sp, struct worker *wrk, struct req *req)
}
}
- SHA256_Init(wrk->sha256ctx);
+ SHA256_Init(req->sha256ctx);
VCL_hash_method(sp);
assert(req->handling == VCL_RET_HASH);
- SHA256_Final(req->digest, wrk->sha256ctx);
+ SHA256_Final(req->digest, req->sha256ctx);
if (!strcmp(req->http->hd[HTTP_HDR_REQ].b, "HEAD"))
req->wantbody = 0;
diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c
index 19395d5..643eb94 100644
--- a/bin/varnishd/cache/cache_hash.c
+++ b/bin/varnishd/cache/cache_hash.c
@@ -158,8 +158,8 @@ HSH_AddString(const struct sess *sp, const char *str)
str = "";
l = strlen(str);
- SHA256_Update(sp->wrk->sha256ctx, str, l);
- SHA256_Update(sp->wrk->sha256ctx, "#", 1);
+ SHA256_Update(sp->req->sha256ctx, str, l);
+ SHA256_Update(sp->req->sha256ctx, "#", 1);
if (cache_param->log_hash)
WSP(sp, SLT_Hash, "%s", str);
diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c
index ee5060f..d26bd8f 100644
--- a/bin/varnishd/cache/cache_session.c
+++ b/bin/varnishd/cache/cache_session.c
@@ -42,6 +42,7 @@
#include "cache.h"
#include "waiter/waiter.h"
+#include "vsha256.h"
#include "vtim.h"
static unsigned ses_size = sizeof (struct sess);
@@ -270,7 +271,10 @@ SES_GetReq(struct sess *sp)
nhttp = (uint16_t)cache_param->http_max_hdr;
hl = HTTP_estimate(nhttp);
- xxxassert(sz > 3 * hl + 128);
+ xxxassert(sz > 3 * hl + sizeof(struct SHA256Context) + 128);
+
+ sp->req->sha256ctx = (void*)p;
+ p += sizeof(struct SHA256Context);
sp->req->http = HTTP_create(p, nhttp);
p += hl; // XXX: align ?
diff --git a/bin/varnishd/cache/cache_wrk.c b/bin/varnishd/cache/cache_wrk.c
index 2e933c5..6087991 100644
--- a/bin/varnishd/cache/cache_wrk.c
+++ b/bin/varnishd/cache/cache_wrk.c
@@ -37,7 +37,6 @@
#include "cache.h"
#include "hash/hash_slinger.h"
-#include "vsha256.h"
static struct lock wstat_mtx;
@@ -140,7 +139,6 @@ wrk_thread_real(void *priv, unsigned shm_workspace, unsigned sess_workspace,
/* XXX: can we trust these to be properly aligned ? */
unsigned char ws[sess_workspace];
struct iovec iov[siov];
- struct SHA256Context sha256;
THR_SetName("cache-worker");
w = &ww;
@@ -149,7 +147,6 @@ wrk_thread_real(void *priv, unsigned shm_workspace, unsigned sess_workspace,
w->lastused = NAN;
w->wlb = w->wlp = wlog;
w->wle = wlog + (sizeof wlog) / 4;
- w->sha256ctx = &sha256;
w->wrw.iov = iov;
w->wrw.siov = siov;
w->wrw.ciov = siov;
More information about the varnish-commit
mailing list