You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by bj...@apache.org on 2010/03/30 15:41:02 UTC
svn commit: r929134 - /apr/apr/trunk/crypto/apr_md5.c
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.