[openssl-commits] [openssl] master update

Richard Levitte levitte at openssl.org
Fri Feb 3 12:50:14 UTC 2017


The branch master has been updated
       via  bc1dba209533f2033a4de0d93380fc0f485e6f7e (commit)
       via  5d5eed4456ebc035893eedbcc4e32a9d065cecb3 (commit)
       via  ec93a2921f6128ac931466ae171fba92a0eab45d (commit)
       via  2accf3f7e013c3d02312afc27cc2edbd1f149db3 (commit)
      from  66bee01c822c5dd26679cad076c52b3d81199668 (commit)


- Log -----------------------------------------------------------------
commit bc1dba209533f2033a4de0d93380fc0f485e6f7e
Author: Dmitry Kostjuchenko <dmitrykos at neutroncode.com>
Date:   Wed Feb 1 12:51:34 2017 +0200

    Grouped data declarations [skip ci]
    Reviewed-by: Rich Salz <rsalz at openssl.org>
    Reviewed-by: Richard Levitte <levitte at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/1981)

commit 5d5eed4456ebc035893eedbcc4e32a9d065cecb3
Author: Dmitry Kostjuchenko <dmitrykos at neutroncode.com>
Date:   Mon Nov 28 20:16:34 2016 +0200

    Removed tab spaces.
    Reviewed-by: Rich Salz <rsalz at openssl.org>
    Reviewed-by: Richard Levitte <levitte at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/1981)

commit ec93a2921f6128ac931466ae171fba92a0eab45d
Author: Dmitry Kostjuchenko <dmitrykos at neutroncode.com>
Date:   Mon Nov 28 19:54:43 2016 +0200

    Corrections according the review comments.
    
    Updated indentations according project rules, renamed file-local define to the shorter version - USE_RWLOCK, fixed declaration after the if statement in CRYPTO_THREAD_lock_new().
    Reviewed-by: Rich Salz <rsalz at openssl.org>
    Reviewed-by: Richard Levitte <levitte at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/1981)

commit 2accf3f7e013c3d02312afc27cc2edbd1f149db3
Author: Dmitry Kostjuchenko <dmitrykos at neutroncode.com>
Date:   Tue Nov 22 18:37:43 2016 +0200

    Compile fix on platforms with missing pthread_rwlock_t.
    
    Fix compilation on platforms with missing pthread_rwlock_t implementation by replacing it with pthread_mutex_t. An example of such platform can be Android OS 2.0 - 2.1, API level 5 (Eclair), Android NDK platform - android-5 where pthread_rwlock_t is not implemented and is missing in pthread.h.
    
    In case of missing pthread_rwlock_t implementation CRYPTO_RWLOCK will work as exclusive lock in write-only mode of pthread_rwlock_t lock.
    
    The implementation based on pthread_mutex_t must be using PTHREAD_MUTEX_RECURSIVE mode to be compatible with recursive behavior of pthread_rwlock_rdlock.
    Reviewed-by: Rich Salz <rsalz at openssl.org>
    Reviewed-by: Richard Levitte <levitte at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/1981)

-----------------------------------------------------------------------

Summary of changes:
 crypto/threads_pthread.c | 41 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/crypto/threads_pthread.c b/crypto/threads_pthread.c
index 5cc48af..151013e 100644
--- a/crypto/threads_pthread.c
+++ b/crypto/threads_pthread.c
@@ -11,8 +11,13 @@
 
 #if defined(OPENSSL_THREADS) && !defined(CRYPTO_TDEBUG) && !defined(OPENSSL_SYS_WINDOWS)
 
+# ifdef PTHREAD_RWLOCK_INITIALIZER
+#  define USE_RWLOCK
+# endif
+
 CRYPTO_RWLOCK *CRYPTO_THREAD_lock_new(void)
 {
+# ifdef USE_RWLOCK
     CRYPTO_RWLOCK *lock = OPENSSL_zalloc(sizeof(pthread_rwlock_t));
     if (lock == NULL)
         return NULL;
@@ -21,30 +26,62 @@ CRYPTO_RWLOCK *CRYPTO_THREAD_lock_new(void)
         OPENSSL_free(lock);
         return NULL;
     }
+# else
+    pthread_mutexattr_t attr;
+    CRYPTO_RWLOCK *lock = OPENSSL_zalloc(sizeof(pthread_mutex_t));
+    if (lock == NULL)
+        return NULL;
+
+    pthread_mutexattr_init(&attr);
+    pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
+
+    if (pthread_mutex_init(lock, &attr) != 0) {
+        pthread_mutexattr_destroy(&attr);
+        OPENSSL_free(lock);
+        return NULL;
+    }
+
+    pthread_mutexattr_destroy(&attr);
+# endif
 
     return lock;
 }
 
 int CRYPTO_THREAD_read_lock(CRYPTO_RWLOCK *lock)
 {
+# ifdef USE_RWLOCK
     if (pthread_rwlock_rdlock(lock) != 0)
         return 0;
+# else
+    if (pthread_mutex_lock(lock) != 0)
+        return 0;
+# endif
 
     return 1;
 }
 
 int CRYPTO_THREAD_write_lock(CRYPTO_RWLOCK *lock)
 {
+# ifdef USE_RWLOCK
     if (pthread_rwlock_wrlock(lock) != 0)
         return 0;
+# else
+    if (pthread_mutex_lock(lock) != 0)
+        return 0;
+# endif
 
     return 1;
 }
 
 int CRYPTO_THREAD_unlock(CRYPTO_RWLOCK *lock)
 {
+# ifdef USE_RWLOCK
     if (pthread_rwlock_unlock(lock) != 0)
         return 0;
+# else
+    if (pthread_mutex_unlock(lock) != 0)
+        return 0;
+# endif
 
     return 1;
 }
@@ -54,7 +91,11 @@ void CRYPTO_THREAD_lock_free(CRYPTO_RWLOCK *lock)
     if (lock == NULL)
         return;
 
+# ifdef USE_RWLOCK
     pthread_rwlock_destroy(lock);
+# else
+    pthread_mutex_destroy(lock);
+# endif
     OPENSSL_free(lock);
 
     return;


More information about the openssl-commits mailing list