Lines Matching refs:cache
1007 cache = std::make_unique<Cache>(); in NetConfig()
1030 std::unique_ptr<Cache> cache; member
1060 static bool cache_has_pending_request_locked(Cache* cache, const Entry* key, in cache_has_pending_request_locked() argument
1062 if (!cache || !key) return false; in cache_has_pending_request_locked()
1064 Cache::pending_req_info* ri = cache->pending_requests.next; in cache_has_pending_request_locked()
1065 Cache::pending_req_info* prev = &cache->pending_requests; in cache_has_pending_request_locked()
1085 static void cache_notify_waiting_tid_locked(struct Cache* cache, const Entry* key) { in cache_notify_waiting_tid_locked() argument
1086 if (!cache || !key) return; in cache_notify_waiting_tid_locked()
1088 Cache::pending_req_info* ri = cache->pending_requests.next; in cache_notify_waiting_tid_locked()
1089 Cache::pending_req_info* prev = &cache->pending_requests; in cache_notify_waiting_tid_locked()
1114 Cache* cache = find_named_cache_locked(netid); in _resolv_cache_query_failed() local
1116 if (cache) { in _resolv_cache_query_failed()
1117 cache_notify_waiting_tid_locked(cache, key); in _resolv_cache_query_failed()
1121 static void cache_dump_mru_locked(Cache* cache) { in cache_dump_mru_locked() argument
1122 std::string buf = fmt::format("MRU LIST ({:2d}): ", cache->num_entries); in cache_dump_mru_locked()
1123 for (Entry* e = cache->mru_list.mru_next; e != &cache->mru_list; e = e->mru_next) { in cache_dump_mru_locked()
1144 static Entry** _cache_lookup_p(Cache* cache, Entry* key) { in _cache_lookup_p() argument
1146 Entry** pnode = (Entry**) &cache->entries[index]; in _cache_lookup_p()
1165 static void _cache_add_p(Cache* cache, Entry** lookup, Entry* e) { in _cache_add_p() argument
1167 e->id = ++cache->last_id; in _cache_add_p()
1168 entry_mru_add(e, &cache->mru_list); in _cache_add_p()
1169 cache->num_entries += 1; in _cache_add_p()
1171 LOG(INFO) << __func__ << ": entry " << e->id << " added (count=" << cache->num_entries << ")"; in _cache_add_p()
1178 static void _cache_remove_p(Cache* cache, Entry** lookup) { in _cache_remove_p() argument
1181 LOG(INFO) << __func__ << ": entry " << e->id << " removed (count=" << cache->num_entries - 1 in _cache_remove_p()
1187 cache->num_entries -= 1; in _cache_remove_p()
1192 static void _cache_remove_oldest(Cache* cache) { in _cache_remove_oldest() argument
1193 Entry* oldest = cache->mru_list.mru_prev; in _cache_remove_oldest()
1194 Entry** lookup = _cache_lookup_p(cache, oldest); in _cache_remove_oldest()
1202 _cache_remove_p(cache, lookup); in _cache_remove_oldest()
1207 static void _cache_remove_expired(Cache* cache) { in _cache_remove_expired() argument
1211 for (e = cache->mru_list.mru_next; e != &cache->mru_list;) { in _cache_remove_expired()
1214 Entry** lookup = _cache_lookup_p(cache, e); in _cache_remove_expired()
1220 _cache_remove_p(cache, lookup); in _cache_remove_expired()
1256 Cache* cache = find_named_cache_locked(netid); in resolv_cache_lookup() local
1257 if (cache == nullptr) { in resolv_cache_lookup()
1264 lookup = _cache_lookup_p(cache, &key); in resolv_cache_lookup()
1270 if (!cache_has_pending_request_locked(cache, &key, true)) { in resolv_cache_lookup()
1279 [netid, &cache, &key]() REQUIRES(cache_mutex) { in resolv_cache_lookup()
1281 cache = find_named_cache_locked(netid); in resolv_cache_lookup()
1282 return !cache_has_pending_request_locked(cache, &key, false); in resolv_cache_lookup()
1284 if (!cache) { in resolv_cache_lookup()
1293 lookup = _cache_lookup_p(cache, &key); in resolv_cache_lookup()
1307 _cache_remove_p(cache, lookup); in resolv_cache_lookup()
1321 if (e != cache->mru_list.mru_next) { in resolv_cache_lookup()
1323 entry_mru_add(e, &cache->mru_list); in resolv_cache_lookup()
1335 Cache* cache = NULL; in resolv_cache_add() local
1346 cache = find_named_cache_locked(netid); in resolv_cache_add()
1347 if (cache == nullptr) { in resolv_cache_add()
1351 lookup = _cache_lookup_p(cache, key); in resolv_cache_add()
1357 cache_notify_waiting_tid_locked(cache, key); in resolv_cache_add()
1361 if (cache->num_entries >= CONFIG_MAX_ENTRIES) { in resolv_cache_add()
1362 _cache_remove_expired(cache); in resolv_cache_add()
1363 if (cache->num_entries >= CONFIG_MAX_ENTRIES) { in resolv_cache_add()
1364 _cache_remove_oldest(cache); in resolv_cache_add()
1367 lookup = _cache_lookup_p(cache, key); in resolv_cache_add()
1371 cache_notify_waiting_tid_locked(cache, key); in resolv_cache_add()
1381 _cache_add_p(cache, lookup, e); in resolv_cache_add()
1385 cache_dump_mru_locked(cache); in resolv_cache_add()
1386 cache_notify_waiting_tid_locked(cache, key); in resolv_cache_add()
1404 Cache* cache = nullptr; in resolv_gethostbyaddr_from_cache() local
1417 cache = find_named_cache_locked(netid); in resolv_gethostbyaddr_from_cache()
1418 if (cache == nullptr) { in resolv_gethostbyaddr_from_cache()
1422 for (node = cache->mru_list.mru_next; node != nullptr && node != &cache->mru_list; in resolv_gethostbyaddr_from_cache()
1515 netconfig->cache->flush(); in resolv_flush_cache_for_net()
1534 if (info != nullptr) return info->cache.get(); in find_named_cache_locked()
1914 Cache* cache; in resolv_cache_get_expiration() local
1916 if (cache = find_named_cache_locked(netid); cache == nullptr) { in resolv_cache_get_expiration()
1920 Entry** lookup = _cache_lookup_p(cache, &key); in resolv_cache_get_expiration()