]> git.sur5r.net Git - openldap/blobdiff - libraries/libldap/tls_o.c
ITS#7428 Use non-blocking IO during SSL Handshake
[openldap] / libraries / libldap / tls_o.c
index 733d18e3656434203eaeb7d5f41300db84c3273e..338e5279696f2504500f939c6be102c44a8e02e8 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2008-2011 The OpenLDAP Foundation.
+ * Copyright 2008-2012 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
 #include "ldap-int.h"
 #include "ldap-tls.h"
 
-#ifdef LDAP_R_COMPILE
-#include <ldap_pvt_thread.h>
-#endif
-
 #ifdef HAVE_OPENSSL_SSL_H
 #include <openssl/ssl.h>
 #include <openssl/x509v3.h>
@@ -505,12 +501,8 @@ tlso_session_chkhost( LDAP *ld, tls_session *sess, const char *name_in )
        }
 
 #ifdef LDAP_PF_INET6
-       if (name[0] == '[' && strchr(name, ']')) {
-               char *n2 = ldap_strdup(name+1);
-               *strchr(n2, ']') = 0;
-               if (inet_pton(AF_INET6, n2, &addr))
-                       ntype = IS_IP6;
-               LDAP_FREE(n2);
+       if (inet_pton(AF_INET6, name, &addr)) {
+               ntype = IS_IP6;
        } else 
 #endif
        if ((ptr = strrchr(name, '.')) && isdigit((unsigned char)ptr[1])) {
@@ -661,10 +653,8 @@ static int
 tlso_session_strength( tls_session *sess )
 {
        tlso_session *s = (tlso_session *)sess;
-       SSL_CIPHER *c;
 
-       c = SSL_get_current_cipher(s);
-       return SSL_CIPHER_get_bits(c, NULL);
+       return SSL_CIPHER_get_bits(SSL_get_current_cipher(s), NULL);
 }
 
 /*
@@ -1214,14 +1204,10 @@ tlso_tmp_dh_cb( SSL *ssl, int is_export, int key_length )
        int i;
 
        /* Do we have params of this length already? */
-#ifdef LDAP_R_COMPILE
-       ldap_pvt_thread_mutex_lock( &tlso_dh_mutex );
-#endif
+       LDAP_MUTEX_LOCK( &tlso_dh_mutex );
        for ( p = tlso_dhparams; p; p=p->next ) {
                if ( p->keylength == key_length ) {
-#ifdef LDAP_R_COMPILE
-                       ldap_pvt_thread_mutex_unlock( &tlso_dh_mutex );
-#endif
+                       LDAP_MUTEX_UNLOCK( &tlso_dh_mutex );
                        return p->param;
                }
        }
@@ -1254,9 +1240,7 @@ tlso_tmp_dh_cb( SSL *ssl, int is_export, int key_length )
                }
        }
 
-#ifdef LDAP_R_COMPILE
-       ldap_pvt_thread_mutex_unlock( &tlso_dh_mutex );
-#endif
+       LDAP_MUTEX_UNLOCK( &tlso_dh_mutex );
        return dh;
 }