[openssl-commits] [openssl] OpenSSL_1_1_0-stable update

Richard Levitte levitte at openssl.org
Fri Feb 3 12:51:31 UTC 2017


The branch OpenSSL_1_1_0-stable has been updated
       via  86d9b572e184262f8c14e8c31f87caa300691d39 (commit)
       via  ddb618d93bf6531c28618f1aabfdc064168fdbfc (commit)
       via  23e6bf041bc5a5404cfa847dba1d2b2878e6f48c (commit)
       via  90078aa018ca13cf80d7ccaaa15a8360631b5110 (commit)
      from  d7155335a56c2bc0d399336c46fefb497cc1131c (commit)


- Log -----------------------------------------------------------------
commit 86d9b572e184262f8c14e8c31f87caa300691d39
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)
    (cherry picked from commit bc1dba209533f2033a4de0d93380fc0f485e6f7e)

commit ddb618d93bf6531c28618f1aabfdc064168fdbfc
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)
    (cherry picked from commit 5d5eed4456ebc035893eedbcc4e32a9d065cecb3)

commit 23e6bf041bc5a5404cfa847dba1d2b2878e6f48c
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)
    (cherry picked from commit ec93a2921f6128ac931466ae171fba92a0eab45d)

commit 90078aa018ca13cf80d7ccaaa15a8360631b5110
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)
    (cherry picked from commit 2accf3f7e013c3d02312afc27cc2edbd1f149db3)

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

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