Commit ec032ae5 authored by Vladislav Vaintroub's avatar Vladislav Vaintroub

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.
parent 903ad7c9
...@@ -419,8 +419,10 @@ void set_wait_timeout(connection_t *connection, ulonglong old_timeout) ...@@ -419,8 +419,10 @@ void set_wait_timeout(connection_t *connection, ulonglong old_timeout)
/* Connection destructor */ /* 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) if (connection->io)
{ {
WaitForThreadpoolIoCallbacks(connection->io, TRUE); WaitForThreadpoolIoCallbacks(connection->io, TRUE);
...@@ -583,10 +585,8 @@ static VOID CALLBACK io_completion_callback(PTP_CALLBACK_INSTANCE instance, ...@@ -583,10 +585,8 @@ static VOID CALLBACK io_completion_callback(PTP_CALLBACK_INSTANCE instance,
error: error:
/* Some error has occured. */ /* Some error has occured. */
if (instance)
DisassociateCurrentThreadFromCallback(instance);
destroy_connection(connection); destroy_connection(connection, instance);
free(connection); free(connection);
} }
...@@ -603,7 +603,7 @@ static void CALLBACK login_callback(PTP_CALLBACK_INSTANCE instance, ...@@ -603,7 +603,7 @@ static void CALLBACK login_callback(PTP_CALLBACK_INSTANCE instance,
connection_t *connection =(connection_t *)context; connection_t *connection =(connection_t *)context;
if (login(connection, instance) != 0) if (login(connection, instance) != 0)
{ {
destroy_connection(connection); destroy_connection(connection, instance);
free(connection); free(connection);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment