apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b..@apache.org
Subject svn commit: r929134 - /apr/apr/trunk/crypto/apr_md5.c
Date Tue, 30 Mar 2010 13:41:02 GMT
Author: bjh
Date: Tue Mar 30 13:41:02 2010
New Revision: 929134

URL: http://svn.apache.org/viewvc?rev=929134&view=rev
Log:
OS/2: Make apr_password_validate() thread safe.

Modified:
    apr/apr/trunk/crypto/apr_md5.c

Modified: apr/apr/trunk/crypto/apr_md5.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/crypto/apr_md5.c?rev=929134&r1=929133&r2=929134&view=diff
==============================================================================
--- apr/apr/trunk/crypto/apr_md5.c (original)
+++ apr/apr/trunk/crypto/apr_md5.c Tue Mar 30 13:41:02 2010
@@ -681,6 +681,32 @@ static void crypt_mutex_unlock(void)
     pthread_mutex_unlock(&crypt_mutex);
 }
 
+#elif defined(OS2)
+
+static HMTX crypt_mutex = 0;
+static void crypt_mutex_lock()
+{
+    if (crypt_mutex == 0) {
+        /* Prevent race condition where two threads could try to create the
+         * mutex concurrently
+         */
+        DosEnterCritSec();
+
+        if (crypt_mutex == 0) {
+            DosCreateMutexSem(NULL, &crypt_mutex, 0, FALSE);
+        }
+
+        DosExitCritSec();
+    }
+
+    DosRequestMutexSem(crypt_mutex, SEM_INDEFINITE_WAIT);
+}
+
+static void crypt_mutex_unlock()
+{
+    DosReleaseMutexSem(crypt_mutex);
+}
+
 #else
 
 #error apr_password_validate() is not threadsafe.  rebuild APR without thread support.



Mime
View raw message