Lines Matching refs:e
791 static void entry_free(Entry* e) { in entry_free() argument
793 if (e) { in entry_free()
794 free(e); in entry_free()
798 static void entry_mru_remove(Entry* e) { in entry_mru_remove() argument
799 e->mru_prev->mru_next = e->mru_next; in entry_mru_remove()
800 e->mru_next->mru_prev = e->mru_prev; in entry_mru_remove()
803 static void entry_mru_add(Entry* e, Entry* list) { in entry_mru_add() argument
806 e->mru_next = first; in entry_mru_add()
807 e->mru_prev = list; in entry_mru_add()
809 list->mru_next = e; in entry_mru_add()
810 first->mru_prev = e; in entry_mru_add()
815 static unsigned entry_hash(const Entry* e) { in entry_hash() argument
818 _dnsPacket_init(pack, e->query, e->querylen); in entry_hash()
824 static int entry_init_key(Entry* e, const void* query, int querylen) { in entry_init_key() argument
827 memset(e, 0, sizeof(*e)); in entry_init_key()
829 e->query = (const uint8_t*) query; in entry_init_key()
830 e->querylen = querylen; in entry_init_key()
831 e->hash = entry_hash(e); in entry_init_key()
833 _dnsPacket_init(pack, e->query, e->querylen); in entry_init_key()
840 Entry* e; in entry_alloc() local
843 size = sizeof(*e) + init->querylen + answerlen; in entry_alloc()
844 e = (Entry*) calloc(size, 1); in entry_alloc()
845 if (e == NULL) return e; in entry_alloc()
847 e->hash = init->hash; in entry_alloc()
848 e->query = (const uint8_t*) (e + 1); in entry_alloc()
849 e->querylen = init->querylen; in entry_alloc()
851 memcpy((char*) e->query, init->query, e->querylen); in entry_alloc()
853 e->answer = e->query + e->querylen; in entry_alloc()
854 e->answerlen = answerlen; in entry_alloc()
856 memcpy((char*) e->answer, answer, e->answerlen); in entry_alloc()
858 return e; in entry_alloc()
1083 for (Entry* e = cache->mru_list.mru_next; e != &cache->mru_list; e = e->mru_next) { in cache_dump_mru_locked() local
1084 StringAppendF(&buf, " %d", e->id); in cache_dump_mru_locked()
1125 static void _cache_add_p(Cache* cache, Entry** lookup, Entry* e) { in _cache_add_p() argument
1126 *lookup = e; in _cache_add_p()
1127 e->id = ++cache->last_id; in _cache_add_p()
1128 entry_mru_add(e, &cache->mru_list); in _cache_add_p()
1131 LOG(INFO) << __func__ << ": entry " << e->id << " added (count=" << cache->num_entries << ")"; in _cache_add_p()
1139 Entry* e = *lookup; in _cache_remove_p() local
1141 LOG(INFO) << __func__ << ": entry " << e->id << " removed (count=" << cache->num_entries - 1 in _cache_remove_p()
1144 entry_mru_remove(e); in _cache_remove_p()
1145 *lookup = e->hlink; in _cache_remove_p()
1146 entry_free(e); in _cache_remove_p()
1168 Entry* e; in _cache_remove_expired() local
1171 for (e = cache->mru_list.mru_next; e != &cache->mru_list;) { in _cache_remove_expired()
1173 if (now >= e->expires) { in _cache_remove_expired()
1174 Entry** lookup = _cache_lookup_p(cache, e); in _cache_remove_expired()
1179 e = e->mru_next; in _cache_remove_expired()
1182 e = e->mru_next; in _cache_remove_expired()
1203 Entry* e; in resolv_cache_lookup() local
1225 e = *lookup; in resolv_cache_lookup()
1227 if (e == NULL) { in resolv_cache_lookup()
1254 e = *lookup; in resolv_cache_lookup()
1255 if (e == NULL) { in resolv_cache_lookup()
1264 if (now >= e->expires) { in resolv_cache_lookup()
1266 res_pquery(e->query, e->querylen); in resolv_cache_lookup()
1271 *answerlen = e->answerlen; in resolv_cache_lookup()
1272 if (e->answerlen > answersize) { in resolv_cache_lookup()
1278 memcpy(answer, e->answer, e->answerlen); in resolv_cache_lookup()
1281 if (e != cache->mru_list.mru_next) { in resolv_cache_lookup()
1282 entry_mru_remove(e); in resolv_cache_lookup()
1283 entry_mru_add(e, &cache->mru_list); in resolv_cache_lookup()
1286 LOG(INFO) << __func__ << ": FOUND IN CACHE entry=" << e; in resolv_cache_lookup()
1293 Entry* e; in resolv_cache_add() local
1313 e = *lookup; in resolv_cache_add()
1316 if (e != NULL) { in resolv_cache_add()
1317 LOG(INFO) << __func__ << ": ALREADY IN CACHE (" << e << ") ? IGNORING ADD"; in resolv_cache_add()
1329 e = *lookup; in resolv_cache_add()
1330 if (e != NULL) { in resolv_cache_add()
1331 LOG(INFO) << __func__ << ": ALREADY IN CACHE (" << e << ") ? IGNORING ADD"; in resolv_cache_add()
1339 e = entry_alloc(key, answer, answerlen); in resolv_cache_add()
1340 if (e != NULL) { in resolv_cache_add()
1341 e->expires = ttl + _time_now(); in resolv_cache_add()
1342 _cache_add_p(cache, lookup, e); in resolv_cache_add()
1867 Entry* e = *lookup; in resolv_cache_get_expiration() local
1868 if (e == NULL) { in resolv_cache_get_expiration()
1873 if (_time_now() >= e->expires) { in resolv_cache_get_expiration()
1878 *expiration = e->expires; in resolv_cache_get_expiration()