*/
#define NM_MAXSEG (1280 - 20 - 40)
+/*%
+ * How many isc_nmhandles and isc_nm_uvreqs will we be
+ * caching for reuse in a socket.
+ */
+#define ISC_NM_NMHANDLES_MAX 64
+#define ISC_NM_UVREQS_MAX 64
+
/*
* Define ISC_NETMGR_TRACE to activate tracing of handles and sockets.
* This will impair performance but enables us to quickly determine,
#endif
LINK(isc_nmhandle_t) active_link;
LINK(isc_nmhandle_t) inactive_link;
+
void *opaque;
isc_job_t job;
*/
ISC_LIST(isc_nmhandle_t) inactive_handles;
+ size_t inactive_handles_cur;
+ size_t inactive_handles_max;
+
/*%
* 'active' handles and uvreqs, mostly for debugging purposes.
*/
if (handle != NULL) {
ISC_LIST_DEQUEUE(sock->inactive_handles, handle, inactive_link);
+ sock->inactive_handles_cur--;
+
isc_refcount_init(&handle->references, 1);
INSIST(VALID_NMHANDLE(handle));
return (handle);
#if defined(__SANITIZE_ADDRESS__) || defined(__SANITIZE_THREAD__)
nmhandle_free(sock, handle);
#else
- if (sock->active) {
+ if (sock->active &&
+ sock->inactive_handles_cur < sock->inactive_handles_max)
+ {
+ sock->inactive_handles_cur++;
ISC_LIST_APPEND(sock->inactive_handles, handle, inactive_link);
} else {
nmhandle_free(sock, handle);
isc__nmsocket_init(csock, worker, isc_nm_udpsocket, iface, sock);
csock->recv_cb = sock->recv_cb;
csock->recv_cbarg = sock->recv_cbarg;
+ csock->inactive_handles_max = ISC_NM_NMHANDLES_MAX;
if (mgr->load_balance_sockets) {
csock->fd = isc__nm_udp_lb_socket(mgr,