]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Add trampoline around iocompletionport_createthreads()
authorOndřej Surý <ondrej@sury.org>
Thu, 29 Apr 2021 12:43:45 +0000 (14:43 +0200)
committerOndřej Surý <ondrej@sury.org>
Mon, 3 May 2021 18:21:15 +0000 (20:21 +0200)
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.

lib/isc/win32/socket.c

index 89649641021409e64659a78e3e09118627754007..cf101189f8ac3db7c5e5a355747801c64a96894f 100644 (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]);
        }
 }