2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-30 14:07:59 +00:00

Add trampoline around iocompletionport_createthreads()

On Windows, the iocompletionport_createthreads() didn't use
isc_thread_create() to create new threads for processing IO, but just a
simple CreateThread() function that completely circumvent the
isc_trampoline mechanism to initialize global isc_tid_v.  This lead to
segmentation fault in isc_hp API because '-1' isn't valid index to the
hazard pointer array.

This commit changes the iocompletionport_createthreads() to use
isc_thread_create() instead of CreateThread() to properly initialize
isc_tid_v.
This commit is contained in:
Ondřej Surý 2021-04-29 14:43:45 +02:00
parent 9dedfcdda6
commit cd54bbbd9a

View File

@ -337,7 +337,6 @@ struct isc_socketmgr {
HANDLE hIoCompletionPort;
int maxIOCPThreads;
HANDLE hIOCPThreads[MAX_IOCPTHREADS];
DWORD dwIOCPThreadIds[MAX_IOCPTHREADS];
size_t maxudp;
/*
@ -500,15 +499,8 @@ iocompletionport_createthreads(int total_threads, isc_socketmgr_t *manager) {
* We need at least one
*/
for (i = 0; i < total_threads; i++) {
manager->hIOCPThreads[i] =
CreateThread(NULL, 0, SocketIoThread, manager, 0,
&manager->dwIOCPThreadIds[i]);
if (manager->hIOCPThreads[i] == NULL) {
errval = GetLastError();
strerror_r(errval, strbuf, sizeof(strbuf));
FATAL_ERROR(__FILE__, __LINE__,
"Can't create IOCP thread: %s", strbuf);
}
isc_thread_create(SocketIoThread, manager,
&manager->hIOCPThreads[i]);
}
}