From: wessels <> Date: Tue, 18 Sep 2001 10:10:50 +0000 (+0000) Subject: made struct _digest_nonce_h use 'hash_link hash' directlty instead X-Git-Tag: SQUID_3_0_PRE1~1398 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=10bb99ccbc716efbd15358612b59b273248140a5;p=thirdparty%2Fsquid.git made struct _digest_nonce_h use 'hash_link hash' directlty instead of key,next elements that look just like the hash_link. --- diff --git a/src/auth/digest/auth_digest.cc b/src/auth/digest/auth_digest.cc index febb66f634..b45e3cda7a 100644 --- a/src/auth/digest/auth_digest.cc +++ b/src/auth/digest/auth_digest.cc @@ -1,6 +1,6 @@ /* - * $Id: auth_digest.cc,v 1.4 2001/09/03 10:33:03 robertc Exp $ + * $Id: auth_digest.cc,v 1.5 2001/09/18 04:10:50 wessels Exp $ * * DEBUG: section 29 Authenticator * AUTHOR: Robert Collins @@ -115,9 +115,9 @@ authDigestNonceEncode(digest_nonce_h * nonce) { if (!nonce) return; - if (nonce->nonceb64) - xfree(nonce->nonceb64); - nonce->nonceb64 = xstrdup(base64_encode_bin((char *) &(nonce->noncedata), sizeof(digest_nonce_data))); + if (nonce->hash.key) + xfree(nonce->hash.key); + nonce->hash.key = xstrdup(base64_encode_bin((char *) &(nonce->noncedata), sizeof(digest_nonce_data))); } digest_nonce_h * @@ -172,12 +172,12 @@ authenticateDigestNonceNew() authDigestNonceEncode(newnonce); /* loop until we get a unique nonce. The nonce creation must have a random factor */ - while ((temp = authenticateDigestNonceFindNonce(newnonce->nonceb64))) { + while ((temp = authenticateDigestNonceFindNonce(newnonce->hash.key))) { /* create a new nonce */ newnonce->noncedata.randomdata = random(); authDigestNonceEncode(newnonce); } - hash_join(digest_nonce_cache, (hash_link *) newnonce); + hash_join(digest_nonce_cache, &newnonce->hash); /* the cache's link */ authDigestNonceLink(newnonce); newnonce->flags.incache = 1; @@ -192,10 +192,10 @@ authenticateDigestNonceDelete(digest_nonce_h * nonce) assert(nonce->references == 0); #if UNREACHABLECODE if (nonce->flags.incache) - hash_remove_link(digest_nonce_cache, (hash_link *) nonce); + hash_remove_link(digest_nonce_cache, &nonce->hash); #endif assert(nonce->flags.incache == 0); - safe_free(nonce->nonceb64); + safe_free(nonce->hash.key); memPoolFree(digest_nonce_pool, nonce); } } @@ -254,10 +254,10 @@ authenticateDigestNonceCacheCleanup(void *data) current_time.tv_sec); hash_first(digest_nonce_cache); while ((nonce = ((digest_nonce_h *) hash_next(digest_nonce_cache)))) { - debug(29, 3) ("authenticateDigestNonceCacheCleanup: nonce entry : '%s'\n", nonce->nonceb64); + debug(29, 3) ("authenticateDigestNonceCacheCleanup: nonce entry : '%s'\n", nonce->hash.key); debug(29, 4) ("authenticateDigestNonceCacheCleanup: Creation time: %d\n", nonce->noncedata.creationtime); if (authDigestNonceIsStale(nonce)) { - debug(29, 4) ("authenticateDigestNonceCacheCleanup: Removing nonce %s from cache due to timeout.\n", nonce->nonceb64); + debug(29, 4) ("authenticateDigestNonceCacheCleanup: Removing nonce %s from cache due to timeout.\n", nonce->hash.key); assert(nonce->flags.incache); /* invalidate nonce so future requests fail */ nonce->flags.valid = 0; @@ -306,7 +306,7 @@ authenticateDigestNonceNonceb64(digest_nonce_h * nonce) { if (!nonce) return NULL; - return nonce->nonceb64; + return nonce->hash.key; } digest_nonce_h * @@ -316,10 +316,8 @@ authenticateDigestNonceFindNonce(const char *nonceb64) if (nonceb64 == NULL) return NULL; debug(29, 9) ("authDigestNonceFindNonce:looking for nonceb64 '%s' in the nonce cache.\n", nonceb64); - if ((nonce = hash_lookup(digest_nonce_cache, nonceb64))) - while ((strcmp(nonce->nonceb64, nonceb64)) && (nonce->next)) - nonce = nonce->next; - if ((nonce == NULL) || (strcmp(nonce->nonceb64, nonceb64))) + nonce = hash_lookup(digest_nonce_cache, nonceb64); + if ((nonce == NULL) || (strcmp(nonce->hash.key, nonceb64))) return NULL; debug(29, 9) ("authDigestNonceFindNonce: Found nonce '%d'\n", nonce); return nonce; @@ -398,7 +396,7 @@ authDigestNoncePurge(digest_nonce_h * nonce) return; if (!nonce->flags.incache) return; - hash_remove_link(digest_nonce_cache, (hash_link *) nonce); + hash_remove_link(digest_nonce_cache, &nonce->hash); nonce->flags.incache = 0; /* the cache's link */ authDigestNonceUnlink(nonce); diff --git a/src/auth/digest/auth_digest.h b/src/auth/digest/auth_digest.h index 072e434d5e..9610f2d504 100644 --- a/src/auth/digest/auth_digest.h +++ b/src/auth/digest/auth_digest.h @@ -59,9 +59,7 @@ struct _digest_nonce_data { /* the nonce structure we'll pass around */ struct _digest_nonce_h { - /* the first two items are (hash_link) */ - char *nonceb64; - digest_nonce_h *next; + hash_link hash; /* must be first */ digest_nonce_data noncedata; /* number of uses we've seen of this nonce */ long nc;