r3644 - branches/2.0/varnish-cache/bin/varnishd
tfheen at projects.linpro.no
tfheen at projects.linpro.no
Fri Feb 6 11:25:20 CET 2009
Author: tfheen
Date: 2009-02-06 11:25:20 +0100 (Fri, 06 Feb 2009)
New Revision: 3644
Modified:
branches/2.0/varnish-cache/bin/varnishd/cache.h
branches/2.0/varnish-cache/bin/varnishd/cache_hash.c
branches/2.0/varnish-cache/bin/varnishd/cache_pool.c
Log:
Merge r3444: Add code to calculate a SHA256 over the hash string if param hash_sha256 is set.
Modified: branches/2.0/varnish-cache/bin/varnishd/cache.h
===================================================================
--- branches/2.0/varnish-cache/bin/varnishd/cache.h 2009-02-06 10:20:53 UTC (rev 3643)
+++ branches/2.0/varnish-cache/bin/varnishd/cache.h 2009-02-06 10:25:20 UTC (rev 3644)
@@ -93,6 +93,8 @@
struct vrt_backend;
struct cli_proto;
struct ban;
+struct SHA256Context;
+
struct lock { void *priv; }; // Opaque
/*--------------------------------------------------------------------*/
@@ -202,6 +204,8 @@
unsigned char *wlb, *wlp, *wle;
unsigned wlr;
+
+ struct SHA256Context *sha256ctx;
};
/* Work Request for worker thread ------------------------------------*/
Modified: branches/2.0/varnish-cache/bin/varnishd/cache_hash.c
===================================================================
--- branches/2.0/varnish-cache/bin/varnishd/cache_hash.c 2009-02-06 10:20:53 UTC (rev 3643)
+++ branches/2.0/varnish-cache/bin/varnishd/cache_hash.c 2009-02-06 10:25:20 UTC (rev 3644)
@@ -66,6 +66,7 @@
#include "cache.h"
#include "stevedore.h"
#include "hash_slinger.h"
+#include "vsha256.h"
static const struct hash_slinger *hash;
@@ -219,6 +220,8 @@
if (u)
p += sizeof(const char *) - u;
sp->hashptr = (void*)p;
+ if (params->hash_sha256)
+ SHA256_Init(sp->wrk->sha256ctx);
}
void
@@ -241,6 +244,10 @@
sp->hashptr[sp->ihashptr + 1] = str + l;
sp->ihashptr += 2;
sp->lhashptr += l + 1;
+ if (params->hash_sha256) {
+ SHA256_Update(sp->wrk->sha256ctx, str, l);
+ SHA256_Update(sp->wrk->sha256ctx, "#", 1);
+ }
}
struct object *
@@ -250,6 +257,7 @@
struct http *h;
struct objhead *oh;
struct object *o, *busy_o, *grace_o;
+ unsigned char sha256[32];
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC);
@@ -257,6 +265,10 @@
AN(hash);
w = sp->wrk;
h = sp->http;
+ if (params->hash_sha256) {
+ SHA256_Final(sha256, sp->wrk->sha256ctx);
+ /* WSP(sp, SLT_Debug, "SHA256: <%.32s>", sha256); */
+ }
HSH_Prealloc(sp);
if (sp->objhead != NULL) {
Modified: branches/2.0/varnish-cache/bin/varnishd/cache_pool.c
===================================================================
--- branches/2.0/varnish-cache/bin/varnishd/cache_pool.c 2009-02-06 10:20:53 UTC (rev 3643)
+++ branches/2.0/varnish-cache/bin/varnishd/cache_pool.c 2009-02-06 10:25:20 UTC (rev 3644)
@@ -72,6 +72,7 @@
#include "cache.h"
#include "stevedore.h"
#include "hash_slinger.h"
+#include "vsha256.h"
VTAILQ_HEAD(workerhead, worker);
@@ -269,6 +270,7 @@
struct worker *w, ww;
struct wq *qp;
unsigned char wlog[params->shm_workspace];
+ struct SHA256Context sha256;
THR_SetName("cache-worker");
w = &ww;
@@ -278,6 +280,7 @@
w->lastused = NAN;
w->wlb = w->wlp = wlog;
w->wle = wlog + sizeof wlog;
+ w->sha256ctx = &sha256;
AZ(pthread_cond_init(&w->cond, NULL));
VSL(SLT_WorkThread, 0, "%p start", w);
More information about the varnish-commit
mailing list