Lines Matching refs:tls_session_db

150 int wget_tls_session_get(const wget_tls_session_db *tls_session_db, const char *host, void **data, …  in wget_tls_session_get()  argument
152 if (tls_session_db) { in wget_tls_session_get()
157 …if (wget_hashmap_get(tls_session_db->entries, &tls_session, &tls_sessionp) && tls_sessionp->expire… in wget_tls_session_get()
169 wget_tls_session_db *wget_tls_session_db_init(wget_tls_session_db *tls_session_db) in wget_tls_session_db_init() argument
176 if (!tls_session_db) { in wget_tls_session_db_init()
177 if (!(tls_session_db = wget_calloc(1, sizeof(wget_tls_session_db)))) { in wget_tls_session_db_init()
182 memset(tls_session_db, 0, sizeof(*tls_session_db)); in wget_tls_session_db_init()
186 tls_session_db->entries = entries; in wget_tls_session_db_init()
188 wget_thread_mutex_init(&tls_session_db->mutex); in wget_tls_session_db_init()
190 return tls_session_db; in wget_tls_session_db_init()
193 void wget_tls_session_db_deinit(wget_tls_session_db *tls_session_db) in wget_tls_session_db_deinit() argument
195 if (tls_session_db) { in wget_tls_session_db_deinit()
196 wget_thread_mutex_lock(tls_session_db->mutex); in wget_tls_session_db_deinit()
197 wget_hashmap_free(&tls_session_db->entries); in wget_tls_session_db_deinit()
198 wget_thread_mutex_unlock(tls_session_db->mutex); in wget_tls_session_db_deinit()
200 wget_thread_mutex_destroy(&tls_session_db->mutex); in wget_tls_session_db_deinit()
204 void wget_tls_session_db_free(wget_tls_session_db **tls_session_db) in wget_tls_session_db_free() argument
206 if (tls_session_db) { in wget_tls_session_db_free()
207 wget_tls_session_db_deinit(*tls_session_db); in wget_tls_session_db_free()
208 xfree(*tls_session_db); in wget_tls_session_db_free()
212 void wget_tls_session_db_add(wget_tls_session_db *tls_session_db, wget_tls_session *tls_session) in wget_tls_session_db_add() argument
214 if (!tls_session_db || !tls_session) in wget_tls_session_db_add()
217 wget_thread_mutex_lock(tls_session_db->mutex); in wget_tls_session_db_add()
220 if (wget_hashmap_remove(tls_session_db->entries, tls_session)) { in wget_tls_session_db_add()
221 tls_session_db->changed = 1; in wget_tls_session_db_add()
229 if (wget_hashmap_get(tls_session_db->entries, tls_session, &old)) { in wget_tls_session_db_add()
231 if (wget_hashmap_remove(tls_session_db->entries, old)) in wget_tls_session_db_add()
236 wget_hashmap_put(tls_session_db->entries, tls_session, tls_session); in wget_tls_session_db_add()
237 tls_session_db->changed = 1; in wget_tls_session_db_add()
240 wget_thread_mutex_unlock(tls_session_db->mutex); in wget_tls_session_db_add()
243 static int tls_session_db_load(wget_tls_session_db *tls_session_db, FILE *fp) in tls_session_db_load() argument
257 if (st.st_mtime != tls_session_db->load_time) in tls_session_db_load()
258 tls_session_db->load_time = st.st_mtime; in tls_session_db_load()
326 bool no_change = wget_hashmap_size(tls_session_db->entries) == 0; in tls_session_db_load()
327 wget_tls_session_db_add(tls_session_db, wget_memdup(&tls_session, sizeof(tls_session))); in tls_session_db_load()
329 tls_session_db->changed = 0; in tls_session_db_load()
339 tls_session_db->load_time = 0; // reload on next call to this function in tls_session_db_load()
349 int wget_tls_session_db_load(wget_tls_session_db *tls_session_db, const char *fname) in wget_tls_session_db_load() argument
351 if (!tls_session_db || !fname || !*fname) in wget_tls_session_db_load()
354 if (wget_update_file(fname, (wget_update_load_fn *) tls_session_db_load, NULL, tls_session_db)) { in wget_tls_session_db_load()
374 static int tls_session_db_save(void *tls_session_db, FILE *fp) in tls_session_db_save() argument
376 wget_hashmap *entries = ((wget_tls_session_db *)tls_session_db)->entries; in tls_session_db_save()
395 int wget_tls_session_db_save(wget_tls_session_db *tls_session_db, const char *fname) in wget_tls_session_db_save() argument
399 if (!tls_session_db || !fname || !*fname) in wget_tls_session_db_save()
402 …te_file(fname, (wget_update_load_fn *) tls_session_db_load, tls_session_db_save, tls_session_db)) { in wget_tls_session_db_save()
407 if ((size = wget_hashmap_size(tls_session_db->entries))) in wget_tls_session_db_save()
412 tls_session_db->changed = 0; in wget_tls_session_db_save()
417 int wget_tls_session_db_changed(wget_tls_session_db *tls_session_db) in wget_tls_session_db_changed() argument
419 return tls_session_db ? tls_session_db->changed : 0; in wget_tls_session_db_changed()