]> git.sur5r.net Git - openldap/commitdiff
don't deadlock when a TLS uri is not responding (ITS#6167)
authorPierangelo Masarati <ando@openldap.org>
Thu, 11 Jun 2009 06:51:01 +0000 (06:51 +0000)
committerPierangelo Masarati <ando@openldap.org>
Thu, 11 Jun 2009 06:51:01 +0000 (06:51 +0000)
servers/slapd/back-ldap/back-ldap.h
servers/slapd/back-ldap/bind.c

index 54e55ce6330a220886ea6713960e9265e76dac22..70692457011b423dba273ffb38ded3d52fad02a4 100644 (file)
@@ -245,6 +245,9 @@ typedef struct ldapinfo_t {
         * to be checked for the presence of a certain item */
        BerVarray               li_bvuri;
        ldap_pvt_thread_mutex_t li_uri_mutex;
+       /* hack because when TLS is used we need to lock and let 
+        * the li_urllist_f function to know it's locked */
+       int                     li_uri_mutex_do_not_lock;
 
        LDAP_REBIND_PROC        *li_rebind_f;
        LDAP_URLLIST_PROC       *li_urllist_f;
index 9691f11f6df9a1c60e2c1f802f4e47c693e4ff03..2521b3fbf8dfc227e741a3472de6a88755417f6b 100644 (file)
@@ -691,8 +691,11 @@ ldap_back_prepare_conn( ldapconn_t *lc, Operation *op, SlapReply *rs, ldap_back_
        }
 
        ldap_pvt_thread_mutex_lock( &li->li_uri_mutex );
+       assert( li->li_uri_mutex_do_not_lock == 0 );
+       li->li_uri_mutex_do_not_lock = 1;
        rs->sr_err = ldap_back_start_tls( ld, op->o_protocol, &is_tls,
                        li->li_uri, li->li_flags, li->li_nretries, &rs->sr_text );
+       li->li_uri_mutex_do_not_lock = 0;
        ldap_pvt_thread_mutex_unlock( &li->li_uri_mutex );
        if ( rs->sr_err != LDAP_SUCCESS ) {
                ldap_unbind_ext( ld, NULL, NULL );
@@ -1581,13 +1584,19 @@ ldap_back_default_urllist(
        *urllist = *url;
        *url = NULL;
 
-       ldap_pvt_thread_mutex_lock( &li->li_uri_mutex );
+       if ( !li->li_uri_mutex_do_not_lock ) {
+               ldap_pvt_thread_mutex_lock( &li->li_uri_mutex );
+       }
+
        if ( li->li_uri ) {
                ch_free( li->li_uri );
        }
 
        ldap_get_option( ld, LDAP_OPT_URI, (void *)&li->li_uri );
-       ldap_pvt_thread_mutex_unlock( &li->li_uri_mutex );
+
+       if ( !li->li_uri_mutex_do_not_lock ) {
+               ldap_pvt_thread_mutex_unlock( &li->li_uri_mutex );
+       }
 
        return LDAP_SUCCESS;
 }