Commit 624b3731 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Move sha256 hash context from worker to req

parent 6c148642
...@@ -324,9 +324,6 @@ struct worker { ...@@ -324,9 +324,6 @@ struct worker {
uint32_t *wlb, *wlp, *wle; uint32_t *wlb, *wlp, *wle;
unsigned wlr; unsigned wlr;
/* Lookup stuff */
struct SHA256Context *sha256ctx;
struct ws ws[1]; struct ws ws[1];
struct busyobj *busyobj; struct busyobj *busyobj;
...@@ -622,6 +619,9 @@ struct req { ...@@ -622,6 +619,9 @@ struct req {
struct ws ws[1]; struct ws ws[1];
struct object *obj; struct object *obj;
struct objcore *objcore; struct objcore *objcore;
/* Lookup stuff */
struct SHA256Context *sha256ctx;
}; };
/*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
......
...@@ -1502,10 +1502,10 @@ cnt_recv(struct sess *sp, struct worker *wrk, struct req *req) ...@@ -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); VCL_hash_method(sp);
assert(req->handling == VCL_RET_HASH); 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")) if (!strcmp(req->http->hd[HTTP_HDR_REQ].b, "HEAD"))
req->wantbody = 0; req->wantbody = 0;
......
...@@ -158,8 +158,8 @@ HSH_AddString(const struct sess *sp, const char *str) ...@@ -158,8 +158,8 @@ HSH_AddString(const struct sess *sp, const char *str)
str = ""; str = "";
l = strlen(str); l = strlen(str);
SHA256_Update(sp->wrk->sha256ctx, str, l); SHA256_Update(sp->req->sha256ctx, str, l);
SHA256_Update(sp->wrk->sha256ctx, "#", 1); SHA256_Update(sp->req->sha256ctx, "#", 1);
if (cache_param->log_hash) if (cache_param->log_hash)
WSP(sp, SLT_Hash, "%s", str); WSP(sp, SLT_Hash, "%s", str);
......
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
#include "cache.h" #include "cache.h"
#include "waiter/waiter.h" #include "waiter/waiter.h"
#include "vsha256.h"
#include "vtim.h" #include "vtim.h"
static unsigned ses_size = sizeof (struct sess); static unsigned ses_size = sizeof (struct sess);
...@@ -270,7 +271,10 @@ SES_GetReq(struct sess *sp) ...@@ -270,7 +271,10 @@ SES_GetReq(struct sess *sp)
nhttp = (uint16_t)cache_param->http_max_hdr; nhttp = (uint16_t)cache_param->http_max_hdr;
hl = HTTP_estimate(nhttp); 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); sp->req->http = HTTP_create(p, nhttp);
p += hl; // XXX: align ? p += hl; // XXX: align ?
......
...@@ -37,7 +37,6 @@ ...@@ -37,7 +37,6 @@
#include "cache.h" #include "cache.h"
#include "hash/hash_slinger.h" #include "hash/hash_slinger.h"
#include "vsha256.h"
static struct lock wstat_mtx; static struct lock wstat_mtx;
...@@ -140,7 +139,6 @@ wrk_thread_real(void *priv, unsigned shm_workspace, unsigned sess_workspace, ...@@ -140,7 +139,6 @@ wrk_thread_real(void *priv, unsigned shm_workspace, unsigned sess_workspace,
/* XXX: can we trust these to be properly aligned ? */ /* XXX: can we trust these to be properly aligned ? */
unsigned char ws[sess_workspace]; unsigned char ws[sess_workspace];
struct iovec iov[siov]; struct iovec iov[siov];
struct SHA256Context sha256;
THR_SetName("cache-worker"); THR_SetName("cache-worker");
w = &ww; w = &ww;
...@@ -149,7 +147,6 @@ wrk_thread_real(void *priv, unsigned shm_workspace, unsigned sess_workspace, ...@@ -149,7 +147,6 @@ wrk_thread_real(void *priv, unsigned shm_workspace, unsigned sess_workspace,
w->lastused = NAN; w->lastused = NAN;
w->wlb = w->wlp = wlog; w->wlb = w->wlp = wlog;
w->wle = wlog + (sizeof wlog) / 4; w->wle = wlog + (sizeof wlog) / 4;
w->sha256ctx = &sha256;
w->wrw.iov = iov; w->wrw.iov = iov;
w->wrw.siov = siov; w->wrw.siov = siov;
w->wrw.ciov = siov; w->wrw.ciov = siov;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment