int handle_resume_delete_req(main_server_st * s, struct proc_st *proc, const SessionResumeFetchMsg * req) { tls_cache_st *cache; struct htable_iter iter; size_t key; key = hash_any(req->session_id.data, req->session_id.len, 0); cache = htable_firstval(s->tls_db.ht, &iter, key); while (cache != NULL) { if (req->session_id.len == cache->session_id_size && memcmp(req->session_id.data, cache->session_id, req->session_id.len) == 0) { cache->session_data_size = 0; cache->session_id_size = 0; htable_delval(s->tls_db.ht, &iter); talloc_free(cache); s->tls_db.entries--; return 0; } cache = htable_nextval(s->tls_db.ht, &iter, key); } return 0; }
void expire_tls_sessions(main_server_st * s) { tls_cache_st *cache; struct htable_iter iter; time_t now, exp; now = time(0); cache = htable_first(s->tls_db.ht, &iter); while (cache != NULL) { gnutls_datum_t d; d.data = (void *)cache->session_data; d.size = cache->session_data_size; exp = gnutls_db_check_entry_time(&d); if (now - exp > TLS_SESSION_EXPIRATION_TIME(s->config)) { cache->session_id_size = 0; htable_delval(s->tls_db.ht, &iter); safe_memset(cache->session_data, 0, cache->session_data_size); talloc_free(cache); s->tls_db.entries--; } cache = htable_next(s->tls_db.ht, &iter); } return; }
void cleanup_client_entries(sec_mod_st *sec) { struct htable *db = sec->client_db; client_entry_st *t; struct htable_iter iter; time_t now = time(0); t = htable_first(db, &iter); while (t != NULL) { if (t->time != -1 && (now - t->time) > (sec->config->cookie_timeout + AUTH_SLACK_TIME) && t->in_use == 0) { htable_delval(db, &iter); clean_entry(sec, t); } t = htable_next(db, &iter); } }
void kmscon_hashtable_free(struct kmscon_hashtable *tbl) { struct htable_iter i; struct kmscon_hashentry *entry; if (!tbl) return; for (entry = htable_first(&tbl->tbl, &i); entry; entry = htable_next(&tbl->tbl, &i)) { htable_delval(&tbl->tbl, &i); if (tbl->free_key) tbl->free_key(entry->key); if (tbl->free_value) tbl->free_value(entry->value); free(entry); } htable_clear(&tbl->tbl); free(tbl); }