From ec032ae54bb260eda4e654c1f04d5589a4de0a04 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Wed, 28 Mar 2012 01:11:05 +0200 Subject: [PATCH] Windows threadpool - always disassociate current thread from callback when destroying connection prior to closing callbacks and calling DestroyThreadpoolEnvironment, to make sure callbacks do not wait for themselves to finish. --- sql/threadpool_win.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sql/threadpool_win.cc b/sql/threadpool_win.cc index bf1d4740a13..346f2816e39 100644 --- a/sql/threadpool_win.cc +++ b/sql/threadpool_win.cc @@ -419,8 +419,10 @@ void set_wait_timeout(connection_t *connection, ulonglong old_timeout) /* Connection destructor */ -void destroy_connection(connection_t *connection) +void destroy_connection(connection_t *connection, PTP_CALLBACK_INSTANCE instance) { + if (instance) + DisassociateCurrentThreadFromCallback(instance); if (connection->io) { WaitForThreadpoolIoCallbacks(connection->io, TRUE); @@ -583,10 +585,8 @@ static VOID CALLBACK io_completion_callback(PTP_CALLBACK_INSTANCE instance, error: /* Some error has occured. */ - if (instance) - DisassociateCurrentThreadFromCallback(instance); - destroy_connection(connection); + destroy_connection(connection, instance); free(connection); } @@ -603,7 +603,7 @@ static void CALLBACK login_callback(PTP_CALLBACK_INSTANCE instance, connection_t *connection =(connection_t *)context; if (login(connection, instance) != 0) { - destroy_connection(connection); + destroy_connection(connection, instance); free(connection); } }