mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-31 14:35:26 +00:00
tracing of active sockets and handles
If NETMGR_TRACE is defined, we now maintain a list of active sockets in the netmgr object and a list of active handles in each socket object; by walking the list and printing `backtrace` in a debugger we can see where they were created, to assist in in debugging of reference counting errors. On shutdown, if netmgr finds there are still active sockets after waiting, isc__nm_dump_active() will be called to log the list of active sockets and their underlying handles, along with some details about them.
This commit is contained in:
committed by
Evan Hunt
parent
2f2d60a989
commit
00e04a86c8
@@ -49,6 +49,20 @@
|
||||
#define ISC_NETMGR_RECVBUF_SIZE (65536)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Define 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
|
||||
#define TRACE_SIZE 8
|
||||
|
||||
void
|
||||
isc__nm_dump_active(isc_nm_t *nm);
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Single network event loop worker.
|
||||
*/
|
||||
@@ -104,6 +118,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
|
||||
void *backtrace[TRACE_SIZE];
|
||||
int backtrace_size;
|
||||
LINK(isc_nmhandle_t) active_link;
|
||||
#endif
|
||||
void *opaque;
|
||||
char extra[];
|
||||
};
|
||||
@@ -308,6 +327,10 @@ struct isc_nm {
|
||||
uint32_t idle;
|
||||
uint32_t keepalive;
|
||||
uint32_t advertised;
|
||||
|
||||
#ifdef NETMGR_TRACE
|
||||
ISC_LIST(isc_nmsocket_t) active_sockets;
|
||||
#endif
|
||||
};
|
||||
|
||||
typedef enum isc_nmsocket_type {
|
||||
@@ -524,6 +547,12 @@ struct isc_nmsocket {
|
||||
|
||||
isc_nm_accept_cb_t accept_cb;
|
||||
void *accept_cbarg;
|
||||
#ifdef NETMGR_TRACE
|
||||
void *backtrace[TRACE_SIZE];
|
||||
int backtrace_size;
|
||||
LINK(isc_nmsocket_t) active_link;
|
||||
ISC_LIST(isc_nmhandle_t) active_handles;
|
||||
#endif
|
||||
};
|
||||
|
||||
bool
|
||||
|
Reference in New Issue
Block a user