apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From i...@apache.org
Subject svn commit: r1860744 - in /apr/apr/trunk: include/arch/win32/apr_arch_thread_mutex.h locks/win32/thread_mutex.c
Date Fri, 07 Jun 2019 10:22:43 GMT
Author: ivan
Date: Fri Jun  7 10:22:43 2019
New Revision: 1860744

URL: http://svn.apache.org/viewvc?rev=1860744&view=rev
Log:
Windows platform: Use semaphore object instead of manual reset event to
implement timed unnested apr_thread_mutex_t.

Modified:
    apr/apr/trunk/include/arch/win32/apr_arch_thread_mutex.h
    apr/apr/trunk/locks/win32/thread_mutex.c

Modified: apr/apr/trunk/include/arch/win32/apr_arch_thread_mutex.h
URL: http://svn.apache.org/viewvc/apr/apr/trunk/include/arch/win32/apr_arch_thread_mutex.h?rev=1860744&r1=1860743&r2=1860744&view=diff
==============================================================================
--- apr/apr/trunk/include/arch/win32/apr_arch_thread_mutex.h (original)
+++ apr/apr/trunk/include/arch/win32/apr_arch_thread_mutex.h Fri Jun  7 10:22:43 2019
@@ -21,11 +21,11 @@
 
 typedef enum thread_mutex_type {
     thread_mutex_critical_section,
-    thread_mutex_unnested_event,
+    thread_mutex_unnested_semaphore,
     thread_mutex_nested_mutex
 } thread_mutex_type;
 
-/* handle applies only to unnested_event on all platforms 
+/* handle applies only to unnested_semaphore on all platforms 
  * and nested_mutex on Win9x only.  Otherwise critical_section 
  * is used for NT nexted mutexes providing optimal performance.
  */

Modified: apr/apr/trunk/locks/win32/thread_mutex.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/locks/win32/thread_mutex.c?rev=1860744&r1=1860743&r2=1860744&view=diff
==============================================================================
--- apr/apr/trunk/locks/win32/thread_mutex.c (original)
+++ apr/apr/trunk/locks/win32/thread_mutex.c Fri Jun  7 10:22:43 2019
@@ -48,11 +48,10 @@ APR_DECLARE(apr_status_t) apr_thread_mut
     (*mutex)->pool = pool;
 
     if (flags & APR_THREAD_MUTEX_UNNESTED) {
-        /* Use an auto-reset signaled event, ready to accept one
-         * waiting thread.
+        /* Use semaphore for unnested mutex.
          */
-        (*mutex)->type = thread_mutex_unnested_event;
-        (*mutex)->handle = CreateEvent(NULL, FALSE, TRUE, NULL);
+        (*mutex)->type = thread_mutex_unnested_semaphore;
+        (*mutex)->handle = CreateSemaphore(NULL, 1, 1, NULL);
     }
     else if (flags & APR_THREAD_MUTEX_TIMED) {
         (*mutex)->type = thread_mutex_nested_mutex;
@@ -123,8 +122,8 @@ APR_DECLARE(apr_status_t) apr_thread_mut
     if (mutex->type == thread_mutex_critical_section) {
         LeaveCriticalSection(&mutex->section);
     }
-    else if (mutex->type == thread_mutex_unnested_event) {
-        if (!SetEvent(mutex->handle)) {
+    else if (mutex->type == thread_mutex_unnested_semaphore) {
+        if (!ReleaseSemaphore(mutex->handle, 1, NULL)) {
             return apr_get_os_error();
         }
     }



Mime
View raw message