Skip to content

Commit

Permalink
Merge pull request #52 from sorc1/ssl-cache-usage-optimization
Browse files Browse the repository at this point in the history
ssl_cache_usage optimizations & fixes
  • Loading branch information
kirimedia authored Jan 12, 2023
2 parents 5ae8243 + 775c54a commit 4145ca4
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions src/ngx_http_graphite_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -3355,20 +3355,13 @@ ngx_http_graphite_source_ssl_cache_usage(const ngx_http_graphite_source_t *sourc
ngx_shm_zone_t *shm_zone = SSL_CTX_get_ex_data(ssl_ctx, ngx_ssl_session_cache_index);
if (shm_zone) {
ngx_slab_pool_t *shpool = (ngx_slab_pool_t*)shm_zone->shm.addr;
ngx_uint_t all_pages = shpool->last - shpool->pages;

ngx_shmtx_lock(&shpool->mutex);

ngx_uint_t all_pages = (shpool->end - shpool->start) / ngx_pagesize;
ngx_uint_t free_pages = 0;

ngx_slab_page_t *page;
for (page = shpool->free.next; page != &shpool->free; page = page->next)
free_pages += page->slab;

ngx_shmtx_unlock(&shpool->mutex);
/* we don't call ngx_shmtx_lock(&shpool->mutex) as we read only single integer */
ngx_uint_t free_pages = shpool->pfree;

if (all_pages > 0)
usage = (100 * (all_pages - free_pages)) / all_pages;
usage = ((double)all_pages - free_pages) / all_pages * 100;
}
}
#endif
Expand Down

0 comments on commit 4145ca4

Please sign in to comment.