mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-31 06:25:31 +00:00
Use isc_mem_reget() to handle the internal active handle cache
The netmgr, has an internal cache for freed active handles. This cache was allocated using isc_mem_allocate()/isc_mem_free() API because it was simpler to reallocate the cache when we needed to grow it. The new isc_mem_reget() function could be used here reducing the need to use isc_mem_allocate() API which is tad bit slower than isc_mem_get() API.
This commit is contained in:
@@ -1258,8 +1258,10 @@ nmsocket_cleanup(isc_nmsocket_t *sock, bool dofree FLARG) {
|
||||
isc_astack_destroy(sock->inactivereqs);
|
||||
sock->magic = 0;
|
||||
|
||||
isc_mem_free(sock->mgr->mctx, sock->ah_frees);
|
||||
isc_mem_free(sock->mgr->mctx, sock->ah_handles);
|
||||
isc_mem_put(sock->mgr->mctx, sock->ah_frees,
|
||||
sock->ah_size * sizeof(sock->ah_frees[0]));
|
||||
isc_mem_put(sock->mgr->mctx, sock->ah_handles,
|
||||
sock->ah_size * sizeof(sock->ah_handles[0]));
|
||||
isc_mutex_destroy(&sock->lock);
|
||||
isc_condition_destroy(&sock->scond);
|
||||
#if HAVE_LIBNGHTTP2
|
||||
@@ -1471,9 +1473,9 @@ isc___nmsocket_init(isc_nmsocket_t *sock, isc_nm_t *mgr, isc_nmsocket_type type,
|
||||
isc_nm_attach(mgr, &sock->mgr);
|
||||
sock->uv_handle.handle.data = sock;
|
||||
|
||||
sock->ah_frees = isc_mem_allocate(
|
||||
mgr->mctx, sock->ah_size * sizeof(sock->ah_frees[0]));
|
||||
sock->ah_handles = isc_mem_allocate(
|
||||
sock->ah_frees = isc_mem_get(mgr->mctx,
|
||||
sock->ah_size * sizeof(sock->ah_frees[0]));
|
||||
sock->ah_handles = isc_mem_get(
|
||||
mgr->mctx, sock->ah_size * sizeof(sock->ah_handles[0]));
|
||||
ISC_LINK_INIT(&sock->quotacb, link);
|
||||
for (size_t i = 0; i < 32; i++) {
|
||||
@@ -1638,12 +1640,14 @@ isc___nmhandle_get(isc_nmsocket_t *sock, isc_sockaddr_t *peer,
|
||||
LOCK(&sock->lock);
|
||||
/* We need to add this handle to the list of active handles */
|
||||
if ((size_t)atomic_load(&sock->ah) == sock->ah_size) {
|
||||
sock->ah_frees =
|
||||
isc_mem_reallocate(sock->mgr->mctx, sock->ah_frees,
|
||||
sock->ah_size * 2 * sizeof(size_t));
|
||||
sock->ah_handles = isc_mem_reallocate(
|
||||
sock->ah_frees = isc_mem_reget(
|
||||
sock->mgr->mctx, sock->ah_frees,
|
||||
sock->ah_size * sizeof(sock->ah_frees[0]),
|
||||
sock->ah_size * 2 * sizeof(sock->ah_frees[0]));
|
||||
sock->ah_handles = isc_mem_reget(
|
||||
sock->mgr->mctx, sock->ah_handles,
|
||||
sock->ah_size * 2 * sizeof(isc_nmhandle_t *));
|
||||
sock->ah_size * sizeof(sock->ah_handles[0]),
|
||||
sock->ah_size * 2 * sizeof(sock->ah_handles[0]));
|
||||
|
||||
for (size_t i = sock->ah_size; i < sock->ah_size * 2; i++) {
|
||||
sock->ah_frees[i] = i;
|
||||
|
Reference in New Issue
Block a user