r3694 - branches/2.0/varnish-cache/bin/varnishd

tfheen at projects.linpro.no tfheen at projects.linpro.no
Mon Feb 9 12:33:59 CET 2009


Author: tfheen
Date: 2009-02-09 12:33:59 +0100 (Mon, 09 Feb 2009)
New Revision: 3694

Modified:
   branches/2.0/varnish-cache/bin/varnishd/cache_hash.c
   branches/2.0/varnish-cache/bin/varnishd/hash_classic.c
   branches/2.0/varnish-cache/bin/varnishd/hash_critbit.c
   branches/2.0/varnish-cache/bin/varnishd/heritage.h
   branches/2.0/varnish-cache/bin/varnishd/mgt_param.c
Log:
Merge r3504: Make SHA256 digest standard and use it in hash_classic.c



Modified: branches/2.0/varnish-cache/bin/varnishd/cache_hash.c
===================================================================
--- branches/2.0/varnish-cache/bin/varnishd/cache_hash.c	2009-02-06 21:21:50 UTC (rev 3693)
+++ branches/2.0/varnish-cache/bin/varnishd/cache_hash.c	2009-02-09 11:33:59 UTC (rev 3694)
@@ -214,8 +214,7 @@
 	if (u)
 		p += sizeof(const char *) - u;
 	sp->hashptr = (void*)p;
-	if (params->hash_sha256)
-		SHA256_Init(sp->wrk->sha256ctx);
+	SHA256_Init(sp->wrk->sha256ctx);
 }
 
 void
@@ -238,10 +237,8 @@
 	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);
-	}
+	SHA256_Update(sp->wrk->sha256ctx, str, l);
+	SHA256_Update(sp->wrk->sha256ctx, "#", 1);
 }
 
 struct object *
@@ -260,10 +257,7 @@
 	h = sp->http;
 
 	HSH_Prealloc(sp);
-	if (params->hash_sha256) {
-		SHA256_Final(sp->wrk->nobjhead->digest, sp->wrk->sha256ctx);
-		/* WSP(sp, SLT_Debug, "SHA256: <%.32s>", sha256); */
-	}
+	SHA256_Final(sp->wrk->nobjhead->digest, sp->wrk->sha256ctx);
 	
 	if (sp->objhead != NULL) {
 		CHECK_OBJ_NOTNULL(sp->objhead, OBJHEAD_MAGIC);

Modified: branches/2.0/varnish-cache/bin/varnishd/hash_classic.c
===================================================================
--- branches/2.0/varnish-cache/bin/varnishd/hash_classic.c	2009-02-06 21:21:50 UTC (rev 3693)
+++ branches/2.0/varnish-cache/bin/varnishd/hash_classic.c	2009-02-09 11:33:59 UTC (rev 3694)
@@ -120,19 +120,13 @@
 	struct objhead *oh;
 	struct hcl_hd *hp;
 	unsigned u1, digest;
-	unsigned u, v;
 	int i;
 
 	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
 	CHECK_OBJ_NOTNULL(noh, OBJHEAD_MAGIC);
 
-	digest = ~0U;
-	for (u = 0; u < sp->ihashptr; u += 2) {
-		v = pdiff(sp->hashptr[u], sp->hashptr[u + 1]);
-		digest = crc32(digest, sp->hashptr[u], v);
-	}
-	digest ^= ~0U;
-
+	assert(sizeof noh->digest > sizeof digest);
+	memcpy(&digest, noh->digest, sizeof digest);
 	u1 = digest % hcl_nhash;
 	hp = &hcl_head[u1];
 

Modified: branches/2.0/varnish-cache/bin/varnishd/hash_critbit.c
===================================================================
--- branches/2.0/varnish-cache/bin/varnishd/hash_critbit.c	2009-02-06 21:21:50 UTC (rev 3693)
+++ branches/2.0/varnish-cache/bin/varnishd/hash_critbit.c	2009-02-09 11:33:59 UTC (rev 3694)
@@ -367,7 +367,6 @@
 
 	(void)oh;
 	AZ(pthread_create(&tp, NULL, hcb_cleaner, NULL));
-	assert(params->hash_sha256);
 	assert(sizeof(struct hcb_y) <= sizeof(oh->u));
 	memset(&hcb_root, 0, sizeof hcb_root);
 	hcb_build_bittbl();
@@ -402,7 +401,6 @@
 	struct objhead *oh;
 	unsigned u;
 	
-	assert(params->hash_sha256);
 	oh =  hcb_insert(&hcb_root, noh, 0);
 	if (oh != NULL) {
 		/* Assert that we didn't muck with the tree without lock */

Modified: branches/2.0/varnish-cache/bin/varnishd/heritage.h
===================================================================
--- branches/2.0/varnish-cache/bin/varnishd/heritage.h	2009-02-06 21:21:50 UTC (rev 3693)
+++ branches/2.0/varnish-cache/bin/varnishd/heritage.h	2009-02-09 11:33:59 UTC (rev 3694)
@@ -174,9 +174,6 @@
 	/* Default grace period */
 	unsigned		default_grace;
 
-	/* Use sha256 hasing */
-	unsigned		hash_sha256;
-
 	/* Log hash string to shm */
 	unsigned		log_hash;
 

Modified: branches/2.0/varnish-cache/bin/varnishd/mgt_param.c
===================================================================
--- branches/2.0/varnish-cache/bin/varnishd/mgt_param.c	2009-02-06 21:21:50 UTC (rev 3693)
+++ branches/2.0/varnish-cache/bin/varnishd/mgt_param.c	2009-02-09 11:33:59 UTC (rev 3694)
@@ -710,10 +710,6 @@
 		"NB: Must be specified with -p to have effect.\n",
 		0,
 		"8192", "bytes" },
-	{ "hash_sha256", tweak_bool, &master.hash_sha256, 0, 0,
-		"Use SHA256 compression of hash-strings",
-		0,
-		"on", "bool" },
 	{ "log_hashstring", tweak_bool, &master.log_hash, 0, 0,
 		"Log the hash string to shared memory log.\n",
 		0,



More information about the varnish-commit mailing list