[11/11] ntdll: Implement TpCallbackUnloadDllOnCompletion.

Sebastian Lackner sebastian at fds-team.de
Wed Jul 1 15:58:23 CDT 2015


---
 dlls/ntdll/ntdll.spec   |    1 +
 dlls/ntdll/threadpool.c |   22 +++++++++++++++++++++-
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec
index 03f3af2..134a3f7 100644
--- a/dlls/ntdll/ntdll.spec
+++ b/dlls/ntdll/ntdll.spec
@@ -978,6 +978,7 @@
 @ stdcall TpCallbackReleaseMutexOnCompletion(ptr long)
 @ stdcall TpCallbackReleaseSemaphoreOnCompletion(ptr long long)
 @ stdcall TpCallbackSetEventOnCompletion(ptr long)
+@ stdcall TpCallbackUnloadDllOnCompletion(ptr ptr)
 @ stdcall TpPostWork(ptr)
 @ stdcall TpReleaseCleanupGroup(ptr)
 @ stdcall TpReleaseCleanupGroupMembers(ptr long ptr)
diff --git a/dlls/ntdll/threadpool.c b/dlls/ntdll/threadpool.c
index af4f620..eeb275f 100644
--- a/dlls/ntdll/threadpool.c
+++ b/dlls/ntdll/threadpool.c
@@ -210,6 +210,7 @@ struct threadpool_instance
         HANDLE              semaphore;
         LONG                semaphore_count;
         HANDLE              event;
+        HMODULE             library;
     } cleanup;
 };
 
@@ -1644,6 +1645,7 @@ static void CALLBACK threadpool_worker_proc( void *param )
             instance.cleanup.semaphore          = NULL;
             instance.cleanup.semaphore_count    = 0;
             instance.cleanup.event              = NULL;
+            instance.cleanup.library            = NULL;
 
             switch (object->type)
             {
@@ -1696,7 +1698,12 @@ static void CALLBACK threadpool_worker_proc( void *param )
             }
             if (instance.cleanup.event)
             {
-                NtSetEvent( instance.cleanup.event, NULL );
+                status = NtSetEvent( instance.cleanup.event, NULL );
+                if (status != STATUS_SUCCESS) goto skip_cleanup;
+            }
+            if (instance.cleanup.library)
+            {
+                LdrUnloadDll( instance.cleanup.library );
             }
 
         skip_cleanup:
@@ -1893,6 +1900,19 @@ VOID WINAPI TpCallbackSetEventOnCompletion( TP_CALLBACK_INSTANCE *instance, HAND
 }
 
 /***********************************************************************
+ *           TpCallbackUnloadDllOnCompletion    (NTDLL.@)
+ */
+VOID WINAPI TpCallbackUnloadDllOnCompletion( TP_CALLBACK_INSTANCE *instance, HMODULE module )
+{
+    struct threadpool_instance *this = impl_from_TP_CALLBACK_INSTANCE( instance );
+
+    TRACE( "%p %p\n", instance, module );
+
+    if (!this->cleanup.library)
+        this->cleanup.library = module;
+}
+
+/***********************************************************************
  *           TpPostWork    (NTDLL.@)
  */
 VOID WINAPI TpPostWork( TP_WORK *work )
-- 
2.4.4



More information about the wine-patches mailing list