Lines Matching refs:cache

24 void mbedtls_ssl_cache_init(mbedtls_ssl_cache_context *cache)  in mbedtls_ssl_cache_init()  argument
26 memset(cache, 0, sizeof(mbedtls_ssl_cache_context)); in mbedtls_ssl_cache_init()
28 cache->timeout = MBEDTLS_SSL_CACHE_DEFAULT_TIMEOUT; in mbedtls_ssl_cache_init()
29 cache->max_entries = MBEDTLS_SSL_CACHE_DEFAULT_MAX_ENTRIES; in mbedtls_ssl_cache_init()
32 mbedtls_mutex_init(&cache->mutex); in mbedtls_ssl_cache_init()
37 static int ssl_cache_find_entry(mbedtls_ssl_cache_context *cache, in ssl_cache_find_entry() argument
48 for (cur = cache->chain; cur != NULL; cur = cur->next) { in ssl_cache_find_entry()
50 if (cache->timeout != 0 && in ssl_cache_find_entry()
51 (int) (t - cur->timestamp) > cache->timeout) { in ssl_cache_find_entry()
80 mbedtls_ssl_cache_context *cache = (mbedtls_ssl_cache_context *) data; in mbedtls_ssl_cache_get() local
84 if ((ret = mbedtls_mutex_lock(&cache->mutex)) != 0) { in mbedtls_ssl_cache_get()
89 ret = ssl_cache_find_entry(cache, session_id, session_id_len, &entry); in mbedtls_ssl_cache_get()
105 if (mbedtls_mutex_unlock(&cache->mutex) != 0) { in mbedtls_ssl_cache_get()
130 static int ssl_cache_pick_writing_slot(mbedtls_ssl_cache_context *cache, in ssl_cache_pick_writing_slot() argument
152 for (cur = cache->chain; cur != NULL; cur = cur->next) { in ssl_cache_pick_writing_slot()
169 for (cur = cache->chain; cur != NULL; cur = cur->next) { in ssl_cache_pick_writing_slot()
170 if (cache->timeout != 0 && in ssl_cache_pick_writing_slot()
171 (int) (t - cur->timestamp) > cache->timeout) { in ssl_cache_pick_writing_slot()
184 if (count < cache->max_entries) { in ssl_cache_pick_writing_slot()
193 cache->chain = cur; in ssl_cache_pick_writing_slot()
213 if (cache->chain == NULL) { in ssl_cache_pick_writing_slot()
218 old = cache->chain; in ssl_cache_pick_writing_slot()
219 cache->chain = old->next; in ssl_cache_pick_writing_slot()
252 mbedtls_ssl_cache_context *cache = (mbedtls_ssl_cache_context *) data; in mbedtls_ssl_cache_set() local
259 if ((ret = mbedtls_mutex_lock(&cache->mutex)) != 0) { in mbedtls_ssl_cache_set()
264 ret = ssl_cache_pick_writing_slot(cache, in mbedtls_ssl_cache_set()
308 if (mbedtls_mutex_unlock(&cache->mutex) != 0) { in mbedtls_ssl_cache_set()
326 mbedtls_ssl_cache_context *cache = (mbedtls_ssl_cache_context *) data; in mbedtls_ssl_cache_remove() local
331 if ((ret = mbedtls_mutex_lock(&cache->mutex)) != 0) { in mbedtls_ssl_cache_remove()
336 ret = ssl_cache_find_entry(cache, session_id, session_id_len, &entry); in mbedtls_ssl_cache_remove()
344 if (entry == cache->chain) { in mbedtls_ssl_cache_remove()
345 cache->chain = entry->next; in mbedtls_ssl_cache_remove()
348 for (prev = cache->chain; prev->next != NULL; prev = prev->next) { in mbedtls_ssl_cache_remove()
362 if (mbedtls_mutex_unlock(&cache->mutex) != 0) { in mbedtls_ssl_cache_remove()
371 void mbedtls_ssl_cache_set_timeout(mbedtls_ssl_cache_context *cache, int timeout) in mbedtls_ssl_cache_set_timeout() argument
377 cache->timeout = timeout; in mbedtls_ssl_cache_set_timeout()
381 void mbedtls_ssl_cache_set_max_entries(mbedtls_ssl_cache_context *cache, int max) in mbedtls_ssl_cache_set_max_entries() argument
387 cache->max_entries = max; in mbedtls_ssl_cache_set_max_entries()
390 void mbedtls_ssl_cache_free(mbedtls_ssl_cache_context *cache) in mbedtls_ssl_cache_free() argument
394 cur = cache->chain; in mbedtls_ssl_cache_free()
405 mbedtls_mutex_free(&cache->mutex); in mbedtls_ssl_cache_free()
407 cache->chain = NULL; in mbedtls_ssl_cache_free()