static void cacheex_add_hitcache(struct s_client *cl, ECM_REQUEST *er) { if (!cfg.max_hitcache_time) // we don't want check/save hitcache return; if (!cfg.cacheex_wait_timetab.cevnum) return; uint32_t cacheex_wait_time = get_cacheex_wait_time(er,NULL); if (!cacheex_wait_time) return; CACHE_HIT *result; HIT_KEY search; memset(&search, 0, sizeof(HIT_KEY)); search.caid = er->caid; search.prid = er->prid; search.srvid = er->srvid; SAFE_RWLOCK_WRLOCK(&hitcache_lock); result = find_hash_table(&ht_hitcache, &search, sizeof(HIT_KEY), &cacheex_compare_hitkey); if(!result) // not found, add it! { if(cs_malloc(&result, sizeof(CACHE_HIT))) { memset(result, 0, sizeof(CACHE_HIT)); result->key.caid = er->caid; result->key.prid = er->prid; result->key.srvid = er->srvid; cs_ftime(&result->max_hitcache_time); add_hash_table(&ht_hitcache, &result->ht_node, &ll_hitcache, &result->ll_node, result, &result->key, sizeof(HIT_KEY)); } } if(result) { if(cl) { result->grp |= cl->grp; result->grp_last_max_hitcache_time |= cl->grp; } cs_ftime(&result->time); //always update time; } SAFE_RWLOCK_UNLOCK(&hitcache_lock); }
void add_hitcache(struct s_client *cl, ECM_REQUEST *er) { if (!cfg.max_hitcache_time) //we don't want check/save hitcache return; if (!cfg.cacheex_wait_timetab.n) return; uint32_t cacheex_wait_time = get_cacheex_wait_time(er,NULL); if (!cacheex_wait_time) return; CACHE_HIT *result; HIT_KEY search; memset(&search, 0, sizeof(HIT_KEY)); search.caid = er->caid; search.prid = er->prid; search.srvid = er->srvid; pthread_rwlock_wrlock(&hitcache_lock); result = find_hash_table(&ht_hitcache, &search, sizeof(HIT_KEY), &compare_hitkey); if(!result){ //not found, add it! if(cs_malloc(&result, sizeof(CACHE_HIT))){ memset(result, 0, sizeof(CACHE_HIT)); result->key.caid = er->caid; result->key.prid = er->prid; result->key.srvid = er->srvid; add_hash_table(&ht_hitcache, &result->ht_node, &ll_hitcache, &result->ll_node, result, &result->key, sizeof(HIT_KEY)); } } if(result){ if(cl) result->grp |= cl->grp; cs_ftime(&result->time); //always update time; } pthread_rwlock_unlock(&hitcache_lock); }