Commit 903f1a06 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Reduce the scope of the SHA256 contexts memory demand, we only

need it during vcl_hash{}
parent f5577b72
......@@ -1459,6 +1459,7 @@ static int
cnt_recv(struct sess *sp, struct worker *wrk, struct req *req)
{
unsigned recv_handling;
struct SHA256Context sha256ctx;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
......@@ -1502,10 +1503,12 @@ cnt_recv(struct sess *sp, struct worker *wrk, struct req *req)
}
}
req->sha256ctx = &sha256ctx;
SHA256_Init(req->sha256ctx);
VCL_hash_method(sp);
assert(req->handling == VCL_RET_HASH);
SHA256_Final(req->digest, req->sha256ctx);
req->sha256ctx = NULL;
if (!strcmp(req->http->hd[HTTP_HDR_REQ].b, "HEAD"))
req->wantbody = 0;
......
......@@ -158,6 +158,7 @@ HSH_AddString(const struct sess *sp, const char *str)
str = "";
l = strlen(str);
AN(sp->req->sha256ctx);
SHA256_Update(sp->req->sha256ctx, str, l);
SHA256_Update(sp->req->sha256ctx, "#", 1);
......
......@@ -42,7 +42,6 @@
#include "cache.h"
#include "waiter/waiter.h"
#include "vsha256.h"
#include "vtim.h"
static unsigned ses_size = sizeof (struct sess);
......@@ -271,10 +270,7 @@ SES_GetReq(struct sess *sp)
nhttp = (uint16_t)cache_param->http_max_hdr;
hl = HTTP_estimate(nhttp);
xxxassert(sz > 3 * hl + sizeof(struct SHA256Context) + 128);
sp->req->sha256ctx = (void*)p;
p += sizeof(struct SHA256Context);
xxxassert(sz > 3 * hl + 128);
sp->req->http = HTTP_create(p, nhttp);
p += hl; // XXX: align ?
......
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