From: Ondřej Surý Date: Tue, 3 Jan 2023 07:27:54 +0000 (+0100) Subject: Simplify tracing the reference counting in isc_netmgr X-Git-Tag: v9.19.9~13^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5bbba0d1a18ef81ed4cddbbc785b4beb6c119aa3;p=thirdparty%2Fbind9.git Simplify tracing the reference counting in isc_netmgr Always track the per-worker sockets in the .active_sockets field in the isc__networker_t struct and always track the per-socket handles in the .active_handles field ian the isc_nmsocket_t struct. --- diff --git a/lib/isc/include/isc/netmgr.h b/lib/isc/include/isc/netmgr.h index f672d3e1411..f6cf2b7d824 100644 --- a/lib/isc/include/isc/netmgr.h +++ b/lib/isc/include/isc/netmgr.h @@ -24,6 +24,8 @@ #include #include +#undef ISC_NETMGR_TRACE + #if defined(SO_REUSEPORT_LB) || (defined(SO_REUSEPORT) && defined(__linux__)) #define HAVE_SO_REUSEPORT_LB 1 #endif @@ -146,7 +148,7 @@ isc_nmsocket_set_max_streams(isc_nmsocket_t *listener, * \li 'listener' is a pointer to a valid network manager listener socket. */ -#ifdef NETMGR_TRACE +#ifdef ISC_NETMGR_TRACE #define isc_nmhandle_attach(handle, dest) \ isc__nmhandle_attach(handle, dest, __FILE__, __LINE__, __func__) #define isc_nmhandle_detach(handlep) \ diff --git a/lib/isc/netmgr/http.c b/lib/isc/netmgr/http.c index 4eb5a147b63..0638255f6fc 100644 --- a/lib/isc/netmgr/http.c +++ b/lib/isc/netmgr/http.c @@ -1470,7 +1470,7 @@ isc_nm_httpconnect(isc_nm_t *mgr, isc_sockaddr_t *local, isc_sockaddr_t *peer, } sock = isc_mem_get(worker->mctx, sizeof(*sock)); - isc__nmsocket_init(sock, worker, isc_nm_httpsocket, local); + isc__nmsocket_init(sock, worker, isc_nm_httpsocket, local, NULL); sock->connect_timeout = timeout; sock->connect_cb = cb; @@ -1655,7 +1655,8 @@ server_on_begin_headers_callback(nghttp2_session *ngsession, worker = session->handle->sock->worker; socket = isc_mem_get(worker->mctx, sizeof(isc_nmsocket_t)); isc__nmsocket_init(socket, worker, isc_nm_httpsocket, - (isc_sockaddr_t *)&session->handle->sock->iface); + (isc_sockaddr_t *)&session->handle->sock->iface, + NULL); socket->peer = session->handle->sock->peer; socket->h2 = (isc_nmsocket_h2_t){ .psock = socket, @@ -2501,7 +2502,7 @@ isc_nm_listenhttp(isc_nm_t *mgr, uint32_t workers, isc_sockaddr_t *iface, REQUIRE(isc_tid() == 0); sock = isc_mem_get(worker->mctx, sizeof(*sock)); - isc__nmsocket_init(sock, worker, isc_nm_httplistener, iface); + isc__nmsocket_init(sock, worker, isc_nm_httplistener, iface, NULL); atomic_init(&sock->h2.max_concurrent_streams, NGHTTP2_INITIAL_MAX_CONCURRENT_STREAMS); diff --git a/lib/isc/netmgr/netmgr-int.h b/lib/isc/netmgr/netmgr-int.h index f2c1155b994..f4bb0f0871d 100644 --- a/lib/isc/netmgr/netmgr-int.h +++ b/lib/isc/netmgr/netmgr-int.h @@ -111,17 +111,14 @@ STATIC_ASSERT(ISC_NETMGR_TCP_RECVBUF_SIZE <= ISC_NETMGR_RECVBUF_SIZE, #define NM_MAXSEG (1280 - 20 - 40) /* - * Define NETMGR_TRACE to activate tracing of handles and sockets. + * Define ISC_NETMGR_TRACE to activate tracing of handles and sockets. * This will impair performance but enables us to quickly determine, * if netmgr resources haven't been cleaned up on shutdown, which ones * are still in use. */ -#ifdef NETMGR_TRACE +#if ISC_NETMGR_TRACE #define TRACE_SIZE 8 -void -isc__nm_dump_active(isc_nm_t *nm); - #if defined(__linux__) #include #define gettid() (uint32_t) syscall(SYS_gettid) @@ -129,16 +126,9 @@ isc__nm_dump_active(isc_nm_t *nm); #define gettid() (uint32_t) pthread_self() #endif -#ifdef NETMGR_TRACE_VERBOSE #define NETMGR_TRACE_LOG(format, ...) \ fprintf(stderr, "%" PRIu32 ":%d:%s:%u:%s:" format, gettid(), \ isc_tid(), file, line, func, __VA_ARGS__) -#else -#define NETMGR_TRACE_LOG(format, ...) \ - (void)file; \ - (void)line; \ - (void)func; -#endif #define FLARG_PASS , file, line, func #define FLARG \ @@ -157,9 +147,9 @@ isc__nm_dump_active(isc_nm_t *nm); isc___nm_uvreq_get(req, sock, __FILE__, __LINE__, __func__) #define isc__nm_uvreq_put(req, sock) \ isc___nm_uvreq_put(req, sock, __FILE__, __LINE__, __func__) -#define isc__nmsocket_init(sock, mgr, type, iface) \ - isc___nmsocket_init(sock, mgr, type, iface, __FILE__, __LINE__, \ - __func__) +#define isc__nmsocket_init(sock, mgr, type, iface, parent) \ + isc___nmsocket_init(sock, mgr, type, iface, parent, __FILE__, \ + __LINE__, __func__) #define isc__nmsocket_put(sockp) \ isc___nmsocket_put(sockp, __FILE__, __LINE__, __func__) #define isc__nmsocket_attach(sock, target) \ @@ -181,8 +171,8 @@ isc__nm_dump_active(isc_nm_t *nm); #define FLARG_IEVENT_PASS(ievent) #define isc__nm_uvreq_get(req, sock) isc___nm_uvreq_get(req, sock) #define isc__nm_uvreq_put(req, sock) isc___nm_uvreq_put(req, sock) -#define isc__nmsocket_init(sock, mgr, type, iface) \ - isc___nmsocket_init(sock, mgr, type, iface) +#define isc__nmsocket_init(sock, mgr, type, iface, parent) \ + isc___nmsocket_init(sock, mgr, type, iface, parent) #define isc__nmsocket_put(sockp) isc___nmsocket_put(sockp) #define isc__nmsocket_attach(sock, target) isc___nmsocket_attach(sock, target) #define isc__nmsocket_detach(socketp) isc___nmsocket_detach(socketp) @@ -208,10 +198,16 @@ typedef struct isc__networker { char *recvbuf; char *sendbuf; bool recvbuf_inuse; + + ISC_LIST(isc_nmsocket_t) active_sockets; + } isc__networker_t; ISC_REFCOUNT_DECL(isc__networker); +void +isc__nm_dump_active(isc__networker_t *worker); + /* * A general handle for a connection bound to a networker. For UDP * connections we have peer address here, so both TCP and UDP can be @@ -244,11 +240,11 @@ struct isc_nmhandle { isc_sockaddr_t local; isc_nm_opaquecb_t doreset; /* reset extra callback, external */ isc_nm_opaquecb_t dofree; /* free extra callback, external */ -#ifdef NETMGR_TRACE +#if ISC_NETMGR_TRACE void *backtrace[TRACE_SIZE]; int backtrace_size; - LINK(isc_nmhandle_t) active_link; #endif + LINK(isc_nmhandle_t) active_link; void *opaque; }; @@ -700,10 +696,6 @@ struct isc_nm { atomic_int_fast32_t send_udp_buffer_size; atomic_int_fast32_t recv_tcp_buffer_size; atomic_int_fast32_t send_tcp_buffer_size; - -#ifdef NETMGR_TRACE - ISC_LIST(isc_nmsocket_t) active_sockets; -#endif }; /*% @@ -1030,13 +1022,12 @@ struct isc_nmsocket { bool barriers_initialised; bool manual_read_timer; -#ifdef NETMGR_TRACE +#if ISC_NETMGR_TRACE void *backtrace[TRACE_SIZE]; int backtrace_size; +#endif LINK(isc_nmsocket_t) active_link; ISC_LIST(isc_nmhandle_t) active_handles; - isc_mutex_t tracelock; -#endif }; void @@ -1070,8 +1061,8 @@ isc__nm_free_uvbuf(isc_nmsocket_t *sock, const uv_buf_t *buf); */ isc_nmhandle_t * -isc___nmhandle_get(isc_nmsocket_t *sock, isc_sockaddr_t *peer, - isc_sockaddr_t *local FLARG); +isc___nmhandle_get(isc_nmsocket_t *sock, isc_sockaddr_t const *peer, + isc_sockaddr_t const *local FLARG); /*%< * Get a handle for the socket 'sock', allocating a new one * if there isn't one available in 'sock->inactivehandles'. @@ -1104,7 +1095,8 @@ isc___nm_uvreq_put(isc__nm_uvreq_t **req, isc_nmsocket_t *sock FLARG); void isc___nmsocket_init(isc_nmsocket_t *sock, isc__networker_t *worker, - isc_nmsocket_type type, isc_sockaddr_t *iface FLARG); + isc_nmsocket_type type, isc_sockaddr_t *iface, + isc_nmsocket_t *parent FLARG); /*%< * Initialize socket 'sock', attach it to 'mgr', and set it to type 'type' * and its interface to 'iface'. diff --git a/lib/isc/netmgr/netmgr.c b/lib/isc/netmgr/netmgr.c index 9873635c6d3..613112e8169 100644 --- a/lib/isc/netmgr/netmgr.c +++ b/lib/isc/netmgr/netmgr.c @@ -216,10 +216,6 @@ isc_netmgr_create(isc_mem_t *mctx, isc_loopmgr_t *loopmgr, isc_nm_t **netmgrp) { netmgr->load_balance_sockets = false; #endif -#ifdef NETMGR_TRACE - ISC_LIST_INIT(netmgr->active_sockets); -#endif - /* * Default TCP timeout values. * May be updated by isc_nm_tcptimeouts(). @@ -245,6 +241,7 @@ isc_netmgr_create(isc_mem_t *mctx, isc_loopmgr_t *loopmgr, isc_nm_t **netmgrp) { ISC_NETMGR_RECVBUF_SIZE), .sendbuf = isc_mem_get(loop->mctx, ISC_NETMGR_SENDBUF_SIZE), + .active_sockets = ISC_LIST_INITIALIZER, }; isc_nm_attach(netmgr, &worker->netmgr); @@ -594,16 +591,13 @@ isc___nmsocket_attach(isc_nmsocket_t *sock, isc_nmsocket_t **target FLARG) { * Free all resources inside a socket (including its children if any). */ static void -nmsocket_cleanup(isc_nmsocket_t *sock, bool dofree FLARG) { - isc_nmhandle_t *handle = NULL; - isc__nm_uvreq_t *uvreq = NULL; - +nmsocket_cleanup(isc_nmsocket_t *sock) { REQUIRE(VALID_NMSOCK(sock)); REQUIRE(!isc__nmsocket_active(sock)); - NETMGR_TRACE_LOG("nmsocket_cleanup():%p->references = %" PRIuFAST32 - "\n", - sock, isc_refcount_current(&sock->references)); + isc_nmhandle_t *handle = NULL; + isc__nm_uvreq_t *uvreq = NULL; + isc__networker_t *worker = sock->worker; isc_refcount_destroy(&sock->references); @@ -618,12 +612,8 @@ nmsocket_cleanup(isc_nmsocket_t *sock, bool dofree FLARG) { */ for (size_t i = 0; i < sock->nchildren; i++) { REQUIRE(!atomic_load(&sock->children[i].destroying)); - if (isc_refcount_decrement( - &sock->children[i].references)) - { - nmsocket_cleanup(&sock->children[i], - false FLARG_PASS); - } + isc_refcount_decrementz(&sock->children[i].references); + nmsocket_cleanup(&sock->children[i]); } /* @@ -676,23 +666,18 @@ nmsocket_cleanup(isc_nmsocket_t *sock, bool dofree FLARG) { sock->magic = 0; -#ifdef NETMGR_TRACE - LOCK(&sock->worker->netmgr->lock); - ISC_LIST_UNLINK(sock->worker->netmgr->active_sockets, sock, - active_link); - UNLOCK(&sock->worker->netmgr->lock); - isc_mutex_destroy(&sock->tracelock); -#endif - isc_mutex_destroy(&sock->lock); - if (dofree) { - isc__networker_t *worker = sock->worker; + /* Don't free child socket */ + if (sock->parent == NULL) { + REQUIRE(sock->tid == isc_tid()); + + ISC_LIST_UNLINK(worker->active_sockets, sock, active_link); + isc_mem_put(worker->mctx, sock, sizeof(*sock)); - isc__networker_detach(&worker); - } else { - isc__networker_detach(&sock->worker); } + + isc__networker_detach(&worker); } static void @@ -740,7 +725,12 @@ nmsocket_maybe_destroy(isc_nmsocket_t *sock FLARG) { if (destroy) { atomic_store(&sock->destroying, true); - nmsocket_cleanup(sock, true FLARG_PASS); + if (sock->tid == isc_tid()) { + nmsocket_cleanup(sock); + } else { + isc_async_run(sock->worker->loop, + (isc_job_cb)nmsocket_cleanup, sock); + } } } @@ -854,7 +844,8 @@ isc_nmsocket_close(isc_nmsocket_t **sockp) { void isc___nmsocket_init(isc_nmsocket_t *sock, isc__networker_t *worker, - isc_nmsocket_type type, isc_sockaddr_t *iface FLARG) { + isc_nmsocket_type type, isc_sockaddr_t *iface, + isc_nmsocket_t *parent FLARG) { uint16_t family; REQUIRE(sock != NULL); @@ -869,6 +860,8 @@ isc___nmsocket_init(isc_nmsocket_t *sock, isc__networker_t *worker, .inactivereqs = isc_astack_new(worker->mctx, ISC_NM_REQS_STACK_SIZE), .result = ISC_R_UNSET, + .active_handles = ISC_LIST_INITIALIZER, + .active_link = ISC_LINK_INITIALIZER, }; isc_mutex_init(&sock->lock); @@ -880,14 +873,14 @@ isc___nmsocket_init(isc_nmsocket_t *sock, isc__networker_t *worker, family = AF_UNSPEC; } -#if NETMGR_TRACE + if (parent) { + sock->parent = parent; + } else { + ISC_LIST_APPEND(worker->active_sockets, sock, active_link); + } + +#if ISC_NETMGR_TRACE sock->backtrace_size = isc_backtrace(sock->backtrace, TRACE_SIZE); - ISC_LINK_INIT(sock, active_link); - ISC_LIST_INIT(sock->active_handles); - LOCK(&worker->netmgr->lock); - ISC_LIST_APPEND(worker->netmgr->active_sockets, sock, active_link); - UNLOCK(&worker->netmgr->lock); - isc_mutex_init(&sock->tracelock); #endif isc__networker_attach(worker, &sock->worker); @@ -992,18 +985,18 @@ alloc_handle(isc_nmsocket_t *sock) { isc_nmhandle_t *handle = isc_mem_get(sock->worker->mctx, sizeof(isc_nmhandle_t)); - *handle = (isc_nmhandle_t){ .magic = NMHANDLE_MAGIC }; -#ifdef NETMGR_TRACE - ISC_LINK_INIT(handle, active_link); -#endif + *handle = (isc_nmhandle_t){ + .magic = NMHANDLE_MAGIC, + .active_link = ISC_LINK_INITIALIZER, + }; isc_refcount_init(&handle->references, 1); return (handle); } isc_nmhandle_t * -isc___nmhandle_get(isc_nmsocket_t *sock, isc_sockaddr_t *peer, - isc_sockaddr_t *local FLARG) { +isc___nmhandle_get(isc_nmsocket_t *sock, isc_sockaddr_t const *peer, + isc_sockaddr_t const *local FLARG) { isc_nmhandle_t *handle = NULL; REQUIRE(VALID_NMSOCK(sock)); @@ -1015,6 +1008,7 @@ isc___nmhandle_get(isc_nmsocket_t *sock, isc_sockaddr_t *peer, } else { isc_refcount_init(&handle->references, 1); INSIST(VALID_NMHANDLE(handle)); + ISC_LINK_INIT(handle, active_link); } NETMGR_TRACE_LOG( @@ -1023,7 +1017,7 @@ isc___nmhandle_get(isc_nmsocket_t *sock, isc_sockaddr_t *peer, isc___nmsocket_attach(sock, &handle->sock FLARG_PASS); -#if NETMGR_TRACE +#if ISC_NETMGR_TRACE handle->backtrace_size = isc_backtrace(handle->backtrace, TRACE_SIZE); #endif @@ -1041,11 +1035,7 @@ isc___nmhandle_get(isc_nmsocket_t *sock, isc_sockaddr_t *peer, (void)atomic_fetch_add(&sock->ah, 1); -#ifdef NETMGR_TRACE - LOCK(&sock->tracelock); ISC_LIST_APPEND(sock->active_handles, handle, active_link); - UNLOCK(&sock->tracelock); -#endif switch (sock->type) { case isc_nm_udpsocket: @@ -1125,9 +1115,7 @@ nmhandle_deactivate(isc_nmsocket_t *sock, isc_nmhandle_t *handle) { * destruction. We have to do this now, because at this point the * socket is either unused or still attached to event->sock. */ -#ifdef NETMGR_TRACE ISC_LIST_UNLINK(sock->active_handles, handle, active_link); -#endif ah = atomic_fetch_sub(&sock->ah, 1); INSIST(ah > 0); @@ -2706,11 +2694,10 @@ isc__nmhandle_log(const isc_nmhandle_t *handle, int level, const char *fmt, void isc__nmhandle_set_manual_timer(isc_nmhandle_t *handle, const bool manual) { - isc_nmsocket_t *sock; - REQUIRE(VALID_NMHANDLE(handle)); - sock = handle->sock; - REQUIRE(VALID_NMSOCK(sock)); + REQUIRE(VALID_NMSOCK(handle->sock)); + + isc_nmsocket_t *sock = handle->sock; switch (sock->type) { case isc_nm_tcpsocket: @@ -2730,11 +2717,10 @@ void isc__nmhandle_get_selected_alpn(isc_nmhandle_t *handle, const unsigned char **alpn, unsigned int *alpnlen) { - isc_nmsocket_t *sock; - REQUIRE(VALID_NMHANDLE(handle)); - sock = handle->sock; - REQUIRE(VALID_NMSOCK(sock)); + REQUIRE(VALID_NMSOCK(handle->sock)); + + isc_nmsocket_t *sock = handle->sock; switch (sock->type) { case isc_nm_tlssocket: @@ -2747,12 +2733,11 @@ isc__nmhandle_get_selected_alpn(isc_nmhandle_t *handle, isc_result_t isc_nmhandle_set_tcp_nodelay(isc_nmhandle_t *handle, const bool value) { - isc_result_t result = ISC_R_FAILURE; - isc_nmsocket_t *sock; - REQUIRE(VALID_NMHANDLE(handle)); - sock = handle->sock; - REQUIRE(VALID_NMSOCK(sock)); + REQUIRE(VALID_NMSOCK(handle->sock)); + + isc_result_t result = ISC_R_FAILURE; + isc_nmsocket_t *sock = handle->sock; switch (sock->type) { case isc_nm_tcpsocket: { @@ -2773,7 +2758,7 @@ isc_nmhandle_set_tcp_nodelay(isc_nmhandle_t *handle, const bool value) { return (result); } -#ifdef NETMGR_TRACE +#if ISC_NETMGR_TRACE /* * Dump all active sockets in netmgr. We output to stderr * as the logger might be already shut down. @@ -2821,7 +2806,6 @@ static void nmsocket_dump(isc_nmsocket_t *sock) { isc_nmhandle_t *handle = NULL; - LOCK(&sock->tracelock); fprintf(stderr, "\n=================\n"); fprintf(stderr, "Active %s socket %p, type %s, refs %" PRIuFAST32 "\n", atomic_load(&sock->client) ? "client" : "server", sock, @@ -2854,26 +2838,21 @@ nmsocket_dump(isc_nmsocket_t *sock) { } fprintf(stderr, "\n"); - UNLOCK(&sock->tracelock); } void -isc__nm_dump_active(isc_nm_t *nm) { +isc__nm_dump_active(isc__networker_t *worker) { isc_nmsocket_t *sock = NULL; + bool first = true; - REQUIRE(VALID_NM(nm)); - - LOCK(&nm->lock); - for (sock = ISC_LIST_HEAD(nm->active_sockets); sock != NULL; + for (sock = ISC_LIST_HEAD(worker->active_sockets); sock != NULL; sock = ISC_LIST_NEXT(sock, active_link)) { - static bool first = true; if (first) { fprintf(stderr, "Outstanding sockets\n"); first = false; } nmsocket_dump(sock); } - UNLOCK(&nm->lock); } #endif diff --git a/lib/isc/netmgr/streamdns.c b/lib/isc/netmgr/streamdns.c index 2fbee5cbf96..a2395dd8202 100644 --- a/lib/isc/netmgr/streamdns.c +++ b/lib/isc/netmgr/streamdns.c @@ -248,7 +248,7 @@ streamdns_sock_new(isc__networker_t *worker, const isc_nmsocket_type_t type, type == isc_nm_streamdnslistener); sock = isc_mem_get(worker->mctx, sizeof(*sock)); - isc__nmsocket_init(sock, worker, type, addr); + isc__nmsocket_init(sock, worker, type, addr, NULL); sock->result = ISC_R_UNSET; if (type == isc_nm_streamdnssocket) { uint32_t initial = 0; diff --git a/lib/isc/netmgr/tcp.c b/lib/isc/netmgr/tcp.c index f427279d4c4..c54ba1171d1 100644 --- a/lib/isc/netmgr/tcp.c +++ b/lib/isc/netmgr/tcp.c @@ -284,7 +284,7 @@ isc_nm_tcpconnect(isc_nm_t *mgr, isc_sockaddr_t *local, isc_sockaddr_t *peer, } sock = isc_mem_get(worker->mctx, sizeof(*sock)); - isc__nmsocket_init(sock, worker, isc_nm_tcpsocket, local); + isc__nmsocket_init(sock, worker, isc_nm_tcpsocket, local, NULL); sock->connect_timeout = timeout; sock->fd = fd; @@ -346,8 +346,7 @@ start_tcp_child(isc_nm_t *mgr, isc_sockaddr_t *iface, isc_nmsocket_t *sock, isc_nmsocket_t *csock = &sock->children[tid]; isc__networker_t *worker = &mgr->workers[tid]; - isc__nmsocket_init(csock, worker, isc_nm_tcpsocket, iface); - csock->parent = sock; + isc__nmsocket_init(csock, worker, isc_nm_tcpsocket, iface, sock); csock->accept_cb = sock->accept_cb; csock->accept_cbarg = sock->accept_cbarg; csock->backlog = sock->backlog; @@ -398,7 +397,7 @@ isc_nm_listentcp(isc_nm_t *mgr, uint32_t workers, isc_sockaddr_t *iface, REQUIRE(workers <= mgr->nloops); sock = isc_mem_get(worker->mctx, sizeof(*sock)); - isc__nmsocket_init(sock, worker, isc_nm_tcplistener, iface); + isc__nmsocket_init(sock, worker, isc_nm_tcplistener, iface, NULL); atomic_init(&sock->rchildren, 0); sock->nchildren = (workers == ISC_NM_LISTEN_ALL) ? (uint32_t)mgr->nloops @@ -909,7 +908,7 @@ accept_connection(isc_nmsocket_t *ssock, isc_quota_t *quota) { csock = isc_mem_get(ssock->worker->mctx, sizeof(isc_nmsocket_t)); isc__nmsocket_init(csock, ssock->worker, isc_nm_tcpsocket, - &ssock->iface); + &ssock->iface, NULL); isc__nmsocket_attach(ssock, &csock->server); csock->recv_cb = ssock->recv_cb; csock->recv_cbarg = ssock->recv_cbarg; diff --git a/lib/isc/netmgr/tlsstream.c b/lib/isc/netmgr/tlsstream.c index 94c778577d1..7affda4d14b 100644 --- a/lib/isc/netmgr/tlsstream.c +++ b/lib/isc/netmgr/tlsstream.c @@ -848,7 +848,7 @@ tlslisten_acceptcb(isc_nmhandle_t *handle, isc_result_t result, void *cbarg) { */ tlssock = isc_mem_get(handle->sock->worker->mctx, sizeof(*tlssock)); isc__nmsocket_init(tlssock, handle->sock->worker, isc_nm_tlssocket, - &handle->sock->iface); + &handle->sock->iface, NULL); /* We need to initialize SSL now to reference SSL_CTX properly */ tlsctx = tls_get_listener_tlsctx(tlslistensock, isc_tid()); @@ -908,7 +908,7 @@ isc_nm_listentls(isc_nm_t *mgr, uint32_t workers, isc_sockaddr_t *iface, tlssock = isc_mem_get(worker->mctx, sizeof(*tlssock)); - isc__nmsocket_init(tlssock, worker, isc_nm_tlslistener, iface); + isc__nmsocket_init(tlssock, worker, isc_nm_tlslistener, iface, NULL); tlssock->accept_cb = accept_cb; tlssock->accept_cbarg = accept_cbarg; tls_init_listener_tlsctx(tlssock, sslctx); @@ -1144,7 +1144,7 @@ isc_nm_tlsconnect(isc_nm_t *mgr, isc_sockaddr_t *local, isc_sockaddr_t *peer, } nsock = isc_mem_get(worker->mctx, sizeof(*nsock)); - isc__nmsocket_init(nsock, worker, isc_nm_tlssocket, local); + isc__nmsocket_init(nsock, worker, isc_nm_tlssocket, local, NULL); nsock->connect_cb = cb; nsock->connect_cbarg = cbarg; nsock->connect_timeout = timeout; diff --git a/lib/isc/netmgr/udp.c b/lib/isc/netmgr/udp.c index b06cd2bf600..578842528cd 100644 --- a/lib/isc/netmgr/udp.c +++ b/lib/isc/netmgr/udp.c @@ -97,8 +97,7 @@ start_udp_child(isc_nm_t *mgr, isc_sockaddr_t *iface, isc_nmsocket_t *sock, csock = &sock->children[tid]; - isc__nmsocket_init(csock, worker, isc_nm_udpsocket, iface); - csock->parent = sock; + isc__nmsocket_init(csock, worker, isc_nm_udpsocket, iface, sock); csock->recv_cb = sock->recv_cb; csock->recv_cbarg = sock->recv_cbarg; @@ -146,7 +145,7 @@ isc_nm_listenudp(isc_nm_t *mgr, uint32_t workers, isc_sockaddr_t *iface, REQUIRE(workers <= mgr->nloops); sock = isc_mem_get(worker->mctx, sizeof(isc_nmsocket_t)); - isc__nmsocket_init(sock, worker, isc_nm_udplistener, iface); + isc__nmsocket_init(sock, worker, isc_nm_udplistener, iface, NULL); atomic_init(&sock->rchildren, 0); sock->nchildren = (workers == ISC_NM_LISTEN_ALL) ? (uint32_t)mgr->nloops @@ -284,7 +283,7 @@ isc_nm_routeconnect(isc_nm_t *mgr, isc_nm_cb_t cb, void *cbarg) { } sock = isc_mem_get(worker->mctx, sizeof(*sock)); - isc__nmsocket_init(sock, worker, isc_nm_udpsocket, NULL); + isc__nmsocket_init(sock, worker, isc_nm_udpsocket, NULL, NULL); sock->connect_cb = cb; sock->connect_cbarg = cbarg; @@ -835,7 +834,7 @@ isc_nm_udpconnect(isc_nm_t *mgr, isc_sockaddr_t *local, isc_sockaddr_t *peer, /* Initialize the new socket */ /* FIXME: Use per-worker mempool for new sockets */ sock = isc_mem_get(worker->mctx, sizeof(isc_nmsocket_t)); - isc__nmsocket_init(sock, worker, isc_nm_udpsocket, local); + isc__nmsocket_init(sock, worker, isc_nm_udpsocket, local, NULL); sock->connect_cb = cb; sock->connect_cbarg = cbarg;