MT#55283 convert cookie_cache to int64_t

Change-Id: If94cc69d180a0a17b0973a30800e0770d7d8f413
pull/1855/merge
Richard Fuchs 2 weeks ago
parent 7f84fe590b
commit 8c694b5e2b

@ -22,20 +22,20 @@ INLINE void cookie_cache_state_cleanup(struct cookie_cache_state *s) {
void cookie_cache_init(struct cookie_cache *c) {
cookie_cache_state_init(&c->current);
cookie_cache_state_init(&c->old);
c->swap_time = timeval_from_us(rtpe_now).tv_sec;
c->swap_time_us = rtpe_now;
mutex_init(&c->lock);
cond_init(&c->cond);
}
/* lock must be held */
static void __cookie_cache_check_swap(struct cookie_cache *c) {
if (timeval_from_us(rtpe_now).tv_sec - c->swap_time >= 30) {
if (timeval_from_us(rtpe_now).tv_sec - timeval_from_us(c->swap_time_us).tv_sec >= 30) {
g_hash_table_remove_all(c->old.cookies);
bencode_buffer_free(&c->old.buffer);
swap_ptrs(&c->old.cookies, &c->current.cookies);
c->old.buffer = c->current.buffer;
bencode_buffer_init(&c->current.buffer);
c->swap_time = timeval_from_us(rtpe_now).tv_sec;
c->swap_time_us = rtpe_now;
}
}

@ -43,7 +43,7 @@ struct cookie_cache {
mutex_t lock;
cond_t cond;
struct cookie_cache_state current, old;
time_t swap_time;
int64_t swap_time_us;
};
void cookie_cache_init(struct cookie_cache *);

Loading…
Cancel
Save