From: Ondřej Surý Date: Thu, 29 Apr 2021 12:43:45 +0000 (+0200) Subject: Add trampoline around iocompletionport_createthreads() X-Git-Tag: v9.17.13~22^2 X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=cd54bbbd9ab195a829f965294b8f06d4e5092d0c;p=thirdparty%2Fbind9.git 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. --- diff --git a/lib/isc/win32/socket.c b/lib/isc/win32/socket.c index 89649641021..cf101189f8a 100644 --- a/lib/isc/win32/socket.c +++ b/lib/isc/win32/socket.c @@ -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]); } }