diff --git a/src/cache.c b/src/cache.c index 49673fcb..c86106a8 100644 --- a/src/cache.c +++ b/src/cache.c @@ -22,24 +22,28 @@ typedef struct { } thread_args; _Noreturn static void* check_cache(void* arg) { - __auto_type args = (thread_args*)arg; + const __auto_type args = (thread_args *)arg; + const __auto_type lock = args->lock; + const __auto_type table = args->table; + const __auto_type check_interval = args->check_interval; + free(args); while (true) { - pthread_rwlock_wrlock(args->lock); + pthread_rwlock_wrlock(lock); const time_t now = time(NULL); struct cache *cur, *tmp; - HASH_ITER(hh, not_http_dst_cache, cur, tmp) { - if (difftime(now, cur->last_time) > args->check_interval) { + HASH_ITER(hh, table, cur, tmp) { + if (difftime(now, cur->last_time) > check_interval) { HASH_DEL(not_http_dst_cache, cur); free(cur); } } - pthread_rwlock_unlock(args->lock); + pthread_rwlock_unlock(lock); - sleep(args->check_interval); + sleep(check_interval); } }