From c8abb29f68abf64bacf2dc5a483eedab84b52428 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20Ibarra=20Corretg=C3=A9?= Date: Fri, 25 Jul 2014 20:50:03 +0200 Subject: [PATCH] windows: don't use atexit for cleaning up the threadpool If libuv is loaded as a DLL and is later unloaded deadlocks can happen when running atexit handlers, so we can't use synchronization priomitives or join threads there. For reference see https://github.com/saghul/pyuv/issues/171 --- src/threadpool.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/threadpool.c b/src/threadpool.c index fd1cab56..33890f02 100644 --- a/src/threadpool.c +++ b/src/threadpool.c @@ -108,7 +108,8 @@ static void post(QUEUE* q) { } -static void cleanup(void) { +#ifndef _WIN32 +UV_DESTRUCTOR(static void cleanup(void)) { unsigned int i; if (initialized == 0) @@ -130,6 +131,7 @@ static void cleanup(void) { nthreads = 0; initialized = 0; } +#endif static void init_once(void) { @@ -167,7 +169,6 @@ static void init_once(void) { abort(); initialized = 1; - atexit(cleanup); }