MCPcopy Create free account
hub / github.com/3proxy/3proxy / hashresolv

Function hashresolv

src/auth.c:996–1026  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

994}
995
996unsigned long hashresolv(struct hashtable *ht, const unsigned char* name, unsigned char* value, unsigned *ttl){
997 unsigned char hash[sizeof(unsigned)*4];
998 struct hashentry ** hep;
999 struct hashentry *he;
1000 unsigned index;
1001
1002 pthread_mutex_lock(&hash_mutex);
1003 if(!ht || !ht->hashtable || !name) {
1004 pthread_mutex_unlock(&hash_mutex);
1005 return 0;
1006 }
1007 nametohash(name, hash, (unsigned char *)ht->rnd);
1008 index = hashindex(ht, hash);
1009 for(hep = ht->hashtable + index; (he = *hep)!=NULL; ){
1010 if(he->expires < conf.time) {
1011 (*hep) = he->next;
1012 he->expires = 0;
1013 he->next = ht->hashempty;
1014 ht->hashempty = he;
1015 }
1016 else if(!memcmp(hash, he->hash, sizeof(unsigned)*4)){
1017 if(ttl) *ttl = (unsigned)(he->expires - conf.time);
1018 memcpy(value, he->value, ht->recsize);
1019 pthread_mutex_unlock(&hash_mutex);
1020 return 1;
1021 }
1022 else hep=&(he->next);
1023 }
1024 pthread_mutex_unlock(&hash_mutex);
1025 return 0;
1026}
1027
1028struct nserver nservers[MAXNSERVERS] = {{{0},0}, {{0},0}, {{0},0}, {{0},0}, {{0},0}};
1029struct nserver authnserver;

Callers 1

udpresolveFunction · 0.85

Calls 2

nametohashFunction · 0.85
hashindexFunction · 0.85

Tested by

no test coverage detected