Changeset caa857


Ignore:
Timestamp:
2008-11-25 17:04:47 (5 years ago)
Author:
Poul-Henning Kamp <phk@…>
Branches:
master, 3.0, 4.0, experimental-ims
Children:
b1e4fa
Parents:
e4ccc3
git-author:
Poul-Henning Kamp <phk@…> (2008-11-25 17:04:47)
git-committer:
Poul-Henning Kamp <phk@…> (2008-11-25 17:04:47)
Message:

Add code to calculate a SHA256 over the hash string if param hash_sha256
is set.

git-svn-id:  http://www.varnish-cache.org/svn/trunk/varnish-cache@3444 d4fa192b-c00b-0410-8231-f00ffab90ce4

Location:
bin/varnishd
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • bin/varnishd/cache.h

    r967f85 rcaa857  
    9494struct cli_proto; 
    9595struct ban; 
     96struct SHA256Context; 
     97 
    9698struct lock { void *priv; };            // Opaque 
    9799 
     
    203205        unsigned char           *wlb, *wlp, *wle; 
    204206        unsigned                wlr; 
     207 
     208        struct SHA256Context    *sha256ctx; 
    205209}; 
    206210 
  • bin/varnishd/cache_hash.c

    rd94204 rcaa857  
    6767#include "stevedore.h" 
    6868#include "hash_slinger.h" 
     69#include "vsha256.h" 
    6970 
    7071static const struct hash_slinger *hash; 
     
    220221                p += sizeof(const char *) - u; 
    221222        sp->hashptr = (void*)p; 
     223        if (params->hash_sha256) 
     224                SHA256_Init(sp->wrk->sha256ctx); 
    222225} 
    223226 
     
    242245        sp->ihashptr += 2; 
    243246        sp->lhashptr += l + 1; 
     247        if (params->hash_sha256) { 
     248                SHA256_Update(sp->wrk->sha256ctx, str, l); 
     249                SHA256_Update(sp->wrk->sha256ctx, "#", 1); 
     250        } 
    244251} 
    245252 
     
    251258        struct objhead *oh; 
    252259        struct object *o, *busy_o, *grace_o; 
     260        unsigned char sha256[32]; 
    253261 
    254262        CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); 
     
    258266        w = sp->wrk; 
    259267        h = sp->http; 
     268        if (params->hash_sha256) { 
     269                SHA256_Final(sha256, sp->wrk->sha256ctx); 
     270                /* WSP(sp, SLT_Debug, "SHA256: <%.32s>", sha256); */ 
     271        } 
    260272 
    261273        HSH_Prealloc(sp); 
  • bin/varnishd/cache_pool.c

    re4ccc3 rcaa857  
    7373#include "stevedore.h" 
    7474#include "hash_slinger.h" 
     75#include "vsha256.h" 
    7576 
    7677VTAILQ_HEAD(workerhead, worker); 
     
    270271        struct wq *qp; 
    271272        unsigned char wlog[params->shm_workspace]; 
     273        struct SHA256Context sha256; 
    272274 
    273275        THR_SetName("cache-worker"); 
     
    279281        w->wlb = w->wlp = wlog; 
    280282        w->wle = wlog + sizeof wlog; 
     283        w->sha256ctx = &sha256; 
    281284        AZ(pthread_cond_init(&w->cond, NULL)); 
    282285 
Note: See TracChangeset for help on using the changeset viewer.