Sebastian Lackner : ntdll: Implement TpCallbackReleaseSemaphoreOnCompletion.

Alexandre Julliard julliard at wine.codeweavers.com
Thu Jul 2 07:18:07 CDT 2015


Module: wine
Branch: master
Commit: eb39cb1323046778f4d7c34e3d78bf5840c26010
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=eb39cb1323046778f4d7c34e3d78bf5840c26010

Author: Sebastian Lackner <sebastian at fds-team.de>
Date:   Wed Jul  1 22:56:51 2015 +0200

ntdll: Implement TpCallbackReleaseSemaphoreOnCompletion.

---

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

diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec
index 4ccb3e7..8d89c58 100644
--- a/dlls/ntdll/ntdll.spec
+++ b/dlls/ntdll/ntdll.spec
@@ -976,6 +976,7 @@
 @ stdcall TpCallbackLeaveCriticalSectionOnCompletion(ptr ptr)
 @ stdcall TpCallbackMayRunLong(ptr)
 @ stdcall TpCallbackReleaseMutexOnCompletion(ptr long)
+@ stdcall TpCallbackReleaseSemaphoreOnCompletion(ptr long long)
 @ stdcall TpPostWork(ptr)
 @ stdcall TpReleaseCleanupGroup(ptr)
 @ stdcall TpReleaseCleanupGroupMembers(ptr long ptr)
diff --git a/dlls/ntdll/threadpool.c b/dlls/ntdll/threadpool.c
index 28dd88b..46ed810 100644
--- a/dlls/ntdll/threadpool.c
+++ b/dlls/ntdll/threadpool.c
@@ -207,6 +207,8 @@ struct threadpool_instance
     {
         CRITICAL_SECTION    *critical_section;
         HANDLE              mutex;
+        HANDLE              semaphore;
+        LONG                semaphore_count;
     } cleanup;
 };
 
@@ -1608,6 +1610,7 @@ static void CALLBACK threadpool_worker_proc( void *param )
     struct threadpool *pool = param;
     LARGE_INTEGER timeout;
     struct list *ptr;
+    NTSTATUS status;
 
     TRACE( "starting worker thread for pool %p\n", pool );
 
@@ -1637,6 +1640,8 @@ static void CALLBACK threadpool_worker_proc( void *param )
             instance.may_run_long               = object->may_run_long;
             instance.cleanup.critical_section   = NULL;
             instance.cleanup.mutex              = NULL;
+            instance.cleanup.semaphore          = NULL;
+            instance.cleanup.semaphore_count    = 0;
 
             switch (object->type)
             {
@@ -1679,9 +1684,15 @@ static void CALLBACK threadpool_worker_proc( void *param )
             }
             if (instance.cleanup.mutex)
             {
-                NtReleaseMutant( instance.cleanup.mutex, NULL );
+                status = NtReleaseMutant( instance.cleanup.mutex, NULL );
+                if (status != STATUS_SUCCESS) goto skip_cleanup;
+            }
+            if (instance.cleanup.semaphore)
+            {
+                NtReleaseSemaphore( instance.cleanup.semaphore, instance.cleanup.semaphore_count, NULL );
             }
 
+        skip_cleanup:
             RtlEnterCriticalSection( &pool->cs );
             pool->num_busy_workers--;
             object->num_running_callbacks--;
@@ -1846,6 +1857,22 @@ VOID WINAPI TpCallbackReleaseMutexOnCompletion( TP_CALLBACK_INSTANCE *instance,
 }
 
 /***********************************************************************
+ *           TpCallbackReleaseSemaphoreOnCompletion    (NTDLL.@)
+ */
+VOID WINAPI TpCallbackReleaseSemaphoreOnCompletion( TP_CALLBACK_INSTANCE *instance, HANDLE semaphore, DWORD count )
+{
+    struct threadpool_instance *this = impl_from_TP_CALLBACK_INSTANCE( instance );
+
+    TRACE( "%p %p %u\n", instance, semaphore, count );
+
+    if (!this->cleanup.semaphore)
+    {
+        this->cleanup.semaphore = semaphore;
+        this->cleanup.semaphore_count = count;
+    }
+}
+
+/***********************************************************************
  *           TpPostWork    (NTDLL.@)
  */
 VOID WINAPI TpPostWork( TP_WORK *work )




More information about the wine-cvs mailing list