mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-31 06:25:31 +00:00
netmgr: make tcp listening multithreaded.
When listening for TCP connections we create a socket, bind it and then pass it over IPC to all threads - which then listen on in and accept connections. This sounds broken, but it's the official way of dealing with multithreaded TCP listeners in libuv, and works on all platforms supported by libuv.
This commit is contained in:
committed by
Evan Hunt
parent
09c2dbffb5
commit
bc5aae1579
@@ -42,6 +42,12 @@
|
||||
|
||||
ISC_THREAD_LOCAL int isc__nm_tid_v = ISC_NETMGR_TID_UNKNOWN;
|
||||
|
||||
#ifdef WIN32
|
||||
#define NAMED_PIPE_PREFIX "\\\\.\\pipe\\named-ipc"
|
||||
#else
|
||||
#define NAMED_PIPE_PREFIX ".named-ipc"
|
||||
#endif
|
||||
|
||||
static void
|
||||
nmsocket_maybe_destroy(isc_nmsocket_t *sock);
|
||||
static void
|
||||
@@ -497,6 +503,9 @@ async_cb(uv_async_t *handle) {
|
||||
case netievent_tcplisten:
|
||||
isc__nm_async_tcplisten(worker, ievent);
|
||||
break;
|
||||
case netievent_tcpchildlisten:
|
||||
isc__nm_async_tcpchildlisten(worker, ievent);
|
||||
break;
|
||||
case netievent_tcpstartread:
|
||||
isc__nm_async_startread(worker, ievent);
|
||||
break;
|
||||
@@ -509,6 +518,9 @@ async_cb(uv_async_t *handle) {
|
||||
case netievent_tcpstoplisten:
|
||||
isc__nm_async_tcpstoplisten(worker, ievent);
|
||||
break;
|
||||
case netievent_tcpstopchildlisten:
|
||||
isc__nm_async_tcpstopchildlisten(worker, ievent);
|
||||
break;
|
||||
case netievent_tcpclose:
|
||||
isc__nm_async_tcpclose(worker, ievent);
|
||||
break;
|
||||
@@ -790,6 +802,16 @@ isc__nmsocket_init(isc_nmsocket_t *sock, isc_nm_t *mgr,
|
||||
sock->ah_handles[i] = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* XXXWPK Maybe it should be in tmp, maybe it should not
|
||||
* be random?
|
||||
*/
|
||||
strcpy(sock->ipc_pipe_name, NAMED_PIPE_PREFIX);
|
||||
for (int i=strlen(sock->ipc_pipe_name); i<31; i++) {
|
||||
sock->ipc_pipe_name[i] = isc_random8()%24 + 'a';
|
||||
}
|
||||
sock->ipc_pipe_name[31] = '\0';
|
||||
|
||||
isc_mutex_init(&sock->lock);
|
||||
isc_condition_init(&sock->cond);
|
||||
isc_refcount_init(&sock->references, 1);
|
||||
|
Reference in New Issue
Block a user