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

Function hashadd

src/auth.c:963–994  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

961}
962
963void hashadd(struct hashtable *ht, const unsigned char* name, unsigned char* value, time_t expires){
964 struct hashentry * hen, *he;
965 struct hashentry ** hep;
966
967 unsigned index;
968
969 pthread_mutex_lock(&hash_mutex);
970 if(!ht||!value||!name||!ht->hashtable||!ht->hashempty) {
971 pthread_mutex_unlock(&hash_mutex);
972 return;
973 }
974 hen = ht->hashempty;
975 ht->hashempty = ht->hashempty->next;
976 nametohash(name, hen->hash, (unsigned char *)ht->rnd);
977 memcpy(hen->value, value, ht->recsize);
978 hen->expires = expires;
979 hen->next = NULL;
980 index = hashindex(ht, hen->hash);
981
982 for(hep = ht->hashtable + index; (he = *hep)!=NULL; ){
983 if(he->expires < conf.time || !memcmp(hen->hash, he->hash, sizeof(he->hash))) {
984 (*hep) = he->next;
985 he->expires = 0;
986 he->next = ht->hashempty;
987 ht->hashempty = he;
988 }
989 else hep=&(he->next);
990 }
991 hen->next = ht->hashtable[index];
992 ht->hashtable[index] = hen;
993 pthread_mutex_unlock(&hash_mutex);
994}
995
996unsigned long hashresolv(struct hashtable *ht, const unsigned char* name, unsigned char* value, unsigned *ttl){
997 unsigned char hash[sizeof(unsigned)*4];

Callers 2

udpresolveFunction · 0.85
h_nsrecordFunction · 0.85

Calls 2

nametohashFunction · 0.85
hashindexFunction · 0.85

Tested by

no test coverage detected