2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 06:25:31 +00:00

Use isc_uv_export() to pass bound TCP listening socket to child listeners.

For multithreaded TCP listening we need to pass a bound socket to all
listening threads. Instead of using uv_pipe handle passing method which
is quite complex (lots of callbacks, each of them with its own error
handling) we now use isc_uv_export() to export the socket, pass it as a
member of the isc__netievent_tcpchildlisten_t structure, and then
isc_uv_import() it in the child thread, simplifying the process
significantly.
This commit is contained in:
Witold Kręcicki
2020-01-07 12:02:41 +01:00
committed by Evan Hunt
parent c6c0a9fdba
commit 67c1ca9a79
3 changed files with 33 additions and 202 deletions

View File

@@ -29,6 +29,7 @@
#include <isc/sockaddr.h>
#include <isc/thread.h>
#include <isc/util.h>
#include "uv-compat.h"
#define ISC_NETMGR_TID_UNKNOWN -1
@@ -208,9 +209,17 @@ typedef struct isc__netievent__socket_req {
typedef isc__netievent__socket_req_t isc__netievent_tcpconnect_t;
typedef isc__netievent__socket_req_t isc__netievent_tcplisten_t;
typedef isc__netievent__socket_req_t isc__netievent_tcpchildlisten_t;
typedef isc__netievent__socket_req_t isc__netievent_tcpsend_t;
typedef struct isc__netievent__socket_streaminfo {
isc__netievent_type type;
isc_nmsocket_t *sock;
isc_uv_stream_info_t streaminfo;
} isc__netievent__socket_streaminfo_t;
typedef isc__netievent__socket_streaminfo_t isc__netievent_tcpchildlisten_t;
typedef struct isc__netievent__socket_handle {
isc__netievent_type type;
isc_nmsocket_t *sock;
@@ -348,11 +357,6 @@ struct isc_nmsocket {
isc_nmiface_t *iface;
isc_nmhandle_t *tcphandle;
/*% Used to transfer listening TCP sockets to children */
uv_pipe_t ipc;
char ipc_pipe_name[64];
atomic_int_fast32_t schildren;
/*% Extra data allocated at the end of each isc_nmhandle_t */
size_t extrahandlesize;