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 {
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;
};
/*--------------------------------------------------------------------*/
......
......@@ -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;
......
......@@ -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);
......
......@@ -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 ?
......
......@@ -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;
......
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